pub struct Id<T> { /* private fields */ }Expand description
A key that is not a string, spelled once and kept that way.
Id::new(9u16) names its entry 9, Id::new(some_uuid) names it by the
uuid’s own spelling. The rendering is done when the Id is built rather
than at every lookup, which is what a Uuid wants most: 36 characters do
not fit beside the value, so spelling one costs the heap, and this pays it
once for the life of the key instead of once per read.
Entries are listed in the order of the spelling, so Id<u16> lists 10
before 9. A number’s decimal spelling does not order like the number, and
nothing here pretends otherwise - padding it would make the name in the file
something nobody typed.
Implementations§
Trait Implementations§
Source§impl<T> Borrow<str> for Id<T>
So a map keyed by an id can be looked up by the spelling alone, without
building one. Sound because Eq and Hash below answer from the same
spelling, which is what Borrow asks.
impl<T> Borrow<str> for Id<T>
So a map keyed by an id can be looked up by the spelling alone, without
building one. Sound because Eq and Hash below answer from the same
spelling, which is what Borrow asks.
Source§impl<'de, T: Display + FromStr> Deserialize<'de> for Id<T>
impl<'de, T: Display + FromStr> Deserialize<'de> for Id<T>
Source§fn deserialize<D: Deserializer<'de>>(from: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(from: D) -> Result<Self, D::Error>
impl<T> Eq for Id<T>
Source§impl<T> PartialEq for Id<T>
By the spelling, which is what the store is addressed by and what a listing
is ordered by. Two ids that spell alike are one entry whatever they hold.
impl<T> PartialEq for Id<T>
By the spelling, which is what the store is addressed by and what a listing is ordered by. Two ids that spell alike are one entry whatever they hold.