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
Required Methods
fn value_from(src: Src) -> Result<Self, Self::Err>
Convert the given value into an exactly equivalent representation.
Implementors
impl ValueFrom<i8> for i16
impl ValueFrom<i8> for i32
impl ValueFrom<i8> for i64
impl ValueFrom<i8> for u8
impl ValueFrom<i8> for u16
impl ValueFrom<i8> for u32
impl ValueFrom<i8> for u64
impl ValueFrom<i8> for isize
impl ValueFrom<i8> for usize
impl ValueFrom<i16> for i8
impl ValueFrom<i16> for i32
impl ValueFrom<i16> for i64
impl ValueFrom<i16> for u8
impl ValueFrom<i16> for u16
impl ValueFrom<i16> for u32
impl ValueFrom<i16> for u64
impl ValueFrom<i16> for isize
impl ValueFrom<i16> for usize
impl ValueFrom<i32> for i8
impl ValueFrom<i32> for i16
impl ValueFrom<i32> for i64
impl ValueFrom<i32> for u8
impl ValueFrom<i32> for u16
impl ValueFrom<i32> for u32
impl ValueFrom<i32> for u64
impl ValueFrom<i64> for i8
impl ValueFrom<i64> for i16
impl ValueFrom<i64> for i32
impl ValueFrom<i64> for u8
impl ValueFrom<i64> for u16
impl ValueFrom<i64> for u32
impl ValueFrom<i64> for u64
impl ValueFrom<i32> for isize
impl ValueFrom<i32> for usize
impl ValueFrom<i64> for isize
impl ValueFrom<i64> for usize
impl ValueFrom<u8> for i8
impl ValueFrom<u8> for i16
impl ValueFrom<u8> for i32
impl ValueFrom<u8> for i64
impl ValueFrom<u8> for u16
impl ValueFrom<u8> for u32
impl ValueFrom<u8> for u64
impl ValueFrom<u8> for isize
impl ValueFrom<u8> for usize
impl ValueFrom<u16> for i8
impl ValueFrom<u16> for i16
impl ValueFrom<u16> for i32
impl ValueFrom<u16> for i64
impl ValueFrom<u16> for u8
impl ValueFrom<u16> for u32
impl ValueFrom<u16> for u64
impl ValueFrom<u16> for isize
impl ValueFrom<u16> for usize
impl ValueFrom<u32> for i8
impl ValueFrom<u32> for i16
impl ValueFrom<u32> for i32
impl ValueFrom<u32> for i64
impl ValueFrom<u32> for u8
impl ValueFrom<u32> for u16
impl ValueFrom<u32> for u64
impl ValueFrom<u64> for i8
impl ValueFrom<u64> for i16
impl ValueFrom<u64> for i32
impl ValueFrom<u64> for i64
impl ValueFrom<u64> for u8
impl ValueFrom<u64> for u16
impl ValueFrom<u64> for u32
impl ValueFrom<u32> for isize
impl ValueFrom<u32> for usize
impl ValueFrom<u64> for isize
impl ValueFrom<u64> for usize
impl ValueFrom<isize> for i8
impl ValueFrom<isize> for i16
impl ValueFrom<isize> for i32
impl ValueFrom<isize> for i64
impl ValueFrom<isize> for u8
impl ValueFrom<isize> for u16
impl ValueFrom<isize> for u32
impl ValueFrom<isize> for u64
impl ValueFrom<isize> for usize
impl ValueFrom<usize> for i8
impl ValueFrom<usize> for i16
impl ValueFrom<usize> for i32
impl ValueFrom<usize> for i64
impl ValueFrom<usize> for u8
impl ValueFrom<usize> for u16
impl ValueFrom<usize> for u32
impl ValueFrom<usize> for u64
impl ValueFrom<usize> for isize
impl ValueFrom<f32> for f64
impl ValueFrom<i8> for f32
impl ValueFrom<i8> for f64
impl ValueFrom<i16> for f32
impl ValueFrom<i16> for f64
impl ValueFrom<i32> for f32
impl ValueFrom<i32> for f64
impl ValueFrom<i64> for f32
impl ValueFrom<i64> for f64
impl ValueFrom<u8> for f32
impl ValueFrom<u8> for f64
impl ValueFrom<u16> for f32
impl ValueFrom<u16> for f64
impl ValueFrom<u32> for f32
impl ValueFrom<u32> for f64
impl ValueFrom<u64> for f32
impl ValueFrom<u64> for f64
impl ValueFrom<isize> for f32
impl ValueFrom<isize> for f64
impl ValueFrom<usize> for f32
impl ValueFrom<usize> for f64
impl<Src> ValueFrom<Src> for Src