Struct foxbox_taxonomy::util::Id  
            
                [−]
            
        [src]
pub struct Id<T> {
    // some fields omitted
}A unique id for values of a given kind.
Performance
This data structure is tuned for specific use cases and should be used accordingly.
- Using an instances of 
Idas a key in aHashMaporHashSetis much faster than using aString. - Comparing two instances of 
Idis much faster than comparing twoStrings. - Instances of 
Idtake very little memory. - Cloning an instance of 
Idis relatively fast, but should be avoided if possible. - Calling 
Id::new, on the other hand, is very slow. Always prefer cloning to callingId::new. 
(De)serialization
Serialized values of this type are represented by plain strings.
extern crate serde; extern crate serde_json; extern crate foxbox_taxonomy; #[derive(Debug)] struct UniqueId; let my_id = foxbox_taxonomy::util::Id::<UniqueId>::new("Unique Identifier"); assert_eq!(my_id.to_string(), "Unique Identifier"); let my_serialized_id = serde_json::to_string(&my_id).unwrap(); assert_eq!(my_serialized_id, "\"Unique Identifier\""); let my_deserialized_id: foxbox_taxonomy::util::Id<UniqueId> = serde_json::from_str("\"Unique Identifier\"").unwrap(); assert_eq!(my_deserialized_id, my_id);