Trait conv::ValueFrom [] [src]

pub trait ValueFrom<Src>: Sized {
    type Err: Error;
    fn value_from(src: Src) -> Result<Self, Self::Err>;
}

This trait is used to perform an exact, value-preserving conversion.

Where possible, prefer implementing this trait over ValueInto, but prefer using ValueInto for generic constraints.

Details

Implementations of this trait should be reflexive, associative and commutative (in the absence of conversion errors). That is, all possible cycles of ValueFrom conversions (for which each "step" has a defined implementation) should produce the same result, with a given value either being "round-tripped" exactly, or an error being produced.

Associated Types

The error type produced by a failed conversion.

Required Methods

Convert the given value into an exactly equivalent representation.

Implementors