Trait conv::TryFrom
[−]
[src]
pub trait TryFrom<Src>: Sized { type Err: Error; fn try_from(src: Src) -> Result<Self, Self::Err>; }
This trait is used to perform a conversion between different semantic types which might fail.
Where possible, prefer implementing this trait over TryInto, but prefer using TryInto for generic constraints.
Details
Typically, this should be used in cases where you are converting between values whose ranges and/or representations only partially overlap. That the conversion may fail should be a reasonably expected outcome. A standard example of this is converting from integers to enums of unitary variants.
Associated Types
Required Methods
Implementors
impl TryFrom<char> for u32impl TryFrom<char> for usizeimpl TryFrom<char> for isizeimpl TryFrom<char> for i8impl TryFrom<char> for i16impl TryFrom<char> for i32impl TryFrom<char> for u8impl TryFrom<char> for u16impl TryFrom<char> for i64impl TryFrom<char> for u64impl TryFrom<u8> for charimpl TryFrom<u16> for charimpl TryFrom<u32> for charimpl TryFrom<i8> for charimpl TryFrom<i16> for charimpl TryFrom<i32> for charimpl TryFrom<i64> for charimpl TryFrom<isize> for charimpl TryFrom<u64> for charimpl TryFrom<usize> for charimpl<Src> TryFrom<Src> for Src