pub struct Level<'a>(/* private fields */);Expand description
One level of a path: a name, as the store means a name.
Not a run of a joined key. A name holding a separator is still one name -
dark.mode is a level called dark.mode, not two - and the joined form
spells it with the separator doubled. Which is the whole reason this is a
type: the two are the same characters often enough that a &str between them
says nothing, and wrong often enough that it matters.
Borrowed where the level is a run of the joined form, which is every level
whose name carries nothing to escape, and held where it is not. A held name
is a SmolStr, the same way the level list of a path holds one, so a name
of 23 bytes or fewer costs no allocation to keep.
Implementations§
Source§impl<'a> Level<'a>
impl<'a> Level<'a>
Sourcepub fn named(name: &'a str) -> Self
pub fn named(name: &'a str) -> Self
A name a caller wrote or a document holds, taken as the name it is.
The entry point from outside: a level read off a document’s own map, or handed in by whoever is addressing the store. Nothing is checked here beyond what the type says, because a name is any string at all - the empty one included, which every format this library writes lets a member carry.
Sourcepub fn into_owned(self) -> Level<'static>
pub fn into_owned(self) -> Level<'static>
The name with a life of its own.
Trait Implementations§
Source§impl Borrow<str> for Level<'_>
A level is its name, and equality, order and hashing all answer from it -
which is what lets a collection keyed by a level be looked up by one.
impl Borrow<str> for Level<'_>
A level is its name, and equality, order and hashing all answer from it - which is what lets a collection keyed by a level be looked up by one.
impl Eq for Level<'_>
Source§impl Ord for Level<'_>
impl Ord for Level<'_>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for Level<'_>
By the name, whichever form holds it, so a level that was assembled answers
like the one that was borrowed.
impl PartialEq for Level<'_>
By the name, whichever form holds it, so a level that was assembled answers like the one that was borrowed.