[][src]Trait conv::TryFrom

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

type Err: Error

The error type produced by a failed conversion.

Loading content...

Required methods

fn try_from(src: Src) -> Result<Self, Self::Err>

Convert the given value into the subject type.

Loading content...

Implementations on Foreign Types

impl TryFrom<char> for u32[src]

type Err = NoError

impl TryFrom<char> for usize[src]

type Err = NoError

impl TryFrom<char> for isize[src]

type Err = NoError

impl TryFrom<char> for i8[src]

type Err = PosOverflow<char>

impl TryFrom<char> for i16[src]

type Err = PosOverflow<char>

impl TryFrom<char> for i32[src]

type Err = PosOverflow<char>

impl TryFrom<char> for u8[src]

type Err = PosOverflow<char>

impl TryFrom<char> for u16[src]

type Err = PosOverflow<char>

impl TryFrom<char> for i64[src]

type Err = NoError

impl TryFrom<char> for u64[src]

type Err = NoError

impl TryFrom<u8> for char[src]

type Err = NoError

impl TryFrom<u16> for char[src]

type Err = Unrepresentable<u16>

impl TryFrom<u32> for char[src]

type Err = Unrepresentable<u32>

impl TryFrom<i8> for char[src]

type Err = Unrepresentable<i8>

impl TryFrom<i16> for char[src]

type Err = Unrepresentable<i16>

impl TryFrom<i32> for char[src]

type Err = Unrepresentable<i32>

impl TryFrom<i64> for char[src]

type Err = Unrepresentable<i64>

impl TryFrom<isize> for char[src]

type Err = Unrepresentable<isize>

impl TryFrom<u64> for char[src]

type Err = Unrepresentable<u64>

impl TryFrom<usize> for char[src]

type Err = Unrepresentable<usize>

Loading content...

Implementors

impl<Src> TryFrom<Src> for Src[src]

type Err = NoError

Loading content...