Struct secret_tree::Name
source · pub struct Name(/* private fields */);
Expand description
Name of a child SecretTree
.
Used in SecretTree::child()
; see its documentation for more context.
An original str
can be extracted from Name
using AsRef
/ Display
implementations:
const NAME: Name = Name::new("test_name");
assert_eq!(NAME.as_ref(), "test_name");
assert_eq!(NAME.to_string(), "test_name");
Implementations§
source§impl Name
impl Name
sourcepub const fn new(name: &str) -> Self
pub const fn new(name: &str) -> Self
Creates a new Name
.
The supplied string must be no more than MAX_NAME_LEN
bytes in length
and must not contain null chars '\0'
.
This is a constant method, which perform all relevant checks during compilation in a constant context:
const NAME: Name = Name::new("some_name");
For example, this won’t compile since the name is too long (17 chars):
ⓘ
const OVERLY_LONG_NAME: Name = Name::new("Overly long name!");
…And this won’t compile because the name contains a \0
char:
ⓘ
const NAME_WITH_ZERO_CHARS: Name = Name::new("12\03");
§Panics
Panics if name
is overly long or contains null chars.
Use the FromStr
implementation for a fallible / non-panicking alternative.
Trait Implementations§
impl Copy for Name
impl Eq for Name
impl StructuralPartialEq for Name
Auto Trait Implementations§
impl Freeze for Name
impl RefUnwindSafe for Name
impl Send for Name
impl Sync for Name
impl Unpin for Name
impl UnwindSafe for Name
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)