Trait ident::DeriveIdent
[−]
[src]
pub trait DeriveIdent<I: Eq> { fn derive_ident(value: &Self) -> I; }
Derives an identifier
from a value.
DeriveIdent
is a "quality of life" trait when using WithIdent
.
Any type T
which implements this trait can easily be converted into a
WithIdent<T, I>
instance using From
and Into
.
Required Methods
fn derive_ident(value: &Self) -> I
Returns an Identifier
value derived from the passed value
.
Note: this is an associated function, which means that you have to call it as
DeriveIdent::derive_ident(value)
instead of value.derive_ident()
. This is so
that there is no conflict with a method on the inner type.
Examples
assert_eq!(5, DeriveIdent::derive_ident(&5)); //Integer types return themselves by default. let wi = WithIdent::from(5); assert_eq!(wi.get_identifier(), &5); assert_eq!(*wi, 5);