Macro typed_index_collection::impl_id
source · macro_rules! impl_id { ($ty:ty, $gen:ty, $id: ident) => { ... }; ($ty:ty) => { ... }; }
Expand description
Implements the Id trait for an object. For example, if an object Animal has
a field ‘species_id’ which is a pointer toward another Object of type
Species, you can implements Id with the following example. You can also
implement Id for Animal itself (the identifier of an Animal is its own
field that must be named id
).
struct Species {
id: String,
name: String,
}
struct Animal {
id: String,
name: String,
species_id: String,
}
impl_id!(Animal, Species, species_id);
impl_id!(Animal);