Trait ident::DeriveIdent[][src]

pub trait DeriveIdent<I> {
    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

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.ident(), &5);
assert_eq!(*wi, 5);

Implementations on Foreign Types

impl DeriveIdent<usize> for usize
[src]

impl DeriveIdent<isize> for isize
[src]

impl DeriveIdent<u8> for u8
[src]

impl DeriveIdent<i8> for i8
[src]

impl DeriveIdent<u16> for u16
[src]

impl DeriveIdent<i16> for i16
[src]

impl DeriveIdent<u32> for u32
[src]

impl DeriveIdent<i32> for i32
[src]

impl DeriveIdent<u64> for u64
[src]

impl DeriveIdent<i64> for i64
[src]

Implementors