1.34.0[][src]Trait oxidizer::TryFrom

pub trait TryFrom<T> {
    type Error;
    fn try_from(value: T) -> Result<Self, Self::Error>;
}

Simple and safe type conversions that may fail in a controlled way under some circumstances. It is the reciprocal of TryInto.

This is useful when you are doing a type conversion that may trivially succeed but may also need special handling. For example, there is no way to convert an i64 into an i32 using the From trait, because an i64 may contain a value that an i32 cannot represent and so the conversion would lose data. This might be handled by truncating the i64 to an i32 (essentially giving the i64's value modulo i32::MAX) or by simply returning i32::MAX, or by some other method. The From trait is intended for perfect conversions, so the TryFrom trait informs the programmer when a type conversion could go bad and lets them decide how to handle it.

Generic Implementations

  • TryFrom<T> for U implies TryInto<U> for T
  • try_from is reflexive, which means that TryFrom<T> for T is implemented and cannot fail -- the associated Error type for calling T::try_from() on a value of type T is Infallible. When the ! type is stabilized Infallible and ! will be equivalent.

TryFrom<T> can be implemented as follows:

use std::convert::TryFrom;

struct GreaterThanZero(i32);

impl TryFrom<i32> for GreaterThanZero {
    type Error = &'static str;

    fn try_from(value: i32) -> Result<Self, Self::Error> {
        if value <= 0 {
            Err("GreaterThanZero only accepts value superior than zero!")
        } else {
            Ok(GreaterThanZero(value))
        }
    }
}

Examples

As described, i32 implements TryFrom<i64>:

use std::convert::TryFrom;

let big_number = 1_000_000_000_000i64;
// Silently truncates `big_number`, requires detecting
// and handling the truncation after the fact.
let smaller_number = big_number as i32;
assert_eq!(smaller_number, -727379968);

// Returns an error because `big_number` is too big to
// fit in an `i32`.
let try_smaller_number = i32::try_from(big_number);
assert!(try_smaller_number.is_err());

// Returns `Ok(3)`.
let try_successful_smaller_number = i32::try_from(3);
assert!(try_successful_smaller_number.is_ok());

Associated Types

type Error

The type returned in the event of a conversion error.

Loading content...

Required methods

fn try_from(value: T) -> Result<Self, Self::Error>

Performs the conversion.

Loading content...

Implementations on Foreign Types

impl TryFrom<u32> for i32[src]

type Error = TryFromIntError

fn try_from(u: u32) -> Result<i32, <i32 as TryFrom<u32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i32> for u16[src]

type Error = TryFromIntError

fn try_from(u: i32) -> Result<u16, <u16 as TryFrom<i32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i128> for i8[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<i8, <i8 as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u64> for i64[src]

type Error = TryFromIntError

fn try_from(u: u64) -> Result<i64, <i64 as TryFrom<u64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u8> for NonZeroU8[src]

Attempts to convert u8 to NonZeroU8.

impl TryFrom<i128> for isize[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<isize, <isize as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for i16[src]

type Error = TryFromIntError

fn try_from(u: isize) -> Result<i16, <i16 as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i64> for NonZeroI64[src]

Attempts to convert i64 to NonZeroI64.

impl TryFrom<i64> for isize[src]

type Error = TryFromIntError

fn try_from(value: i64) -> Result<isize, <isize as TryFrom<i64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<usize> for u8[src]

type Error = TryFromIntError

fn try_from(u: usize) -> Result<u8, <u8 as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i128> for usize[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<usize, <usize as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u64> for i8[src]

type Error = TryFromIntError

fn try_from(u: u64) -> Result<i8, <i8 as TryFrom<u64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i64> for u8[src]

type Error = TryFromIntError

fn try_from(u: i64) -> Result<u8, <u8 as TryFrom<i64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i32> for isize[src]

type Error = TryFromIntError

fn try_from(value: i32) -> Result<isize, <isize as TryFrom<i32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i64> for u128[src]

type Error = TryFromIntError

fn try_from(u: i64) -> Result<u128, <u128 as TryFrom<i64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl<'_, T, const N: usize> TryFrom<&'_ [T]> for [T; N] where
    T: Copy
[src]

impl TryFrom<usize> for i16[src]

type Error = TryFromIntError

fn try_from(u: usize) -> Result<i16, <i16 as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u32> for i16[src]

type Error = TryFromIntError

fn try_from(u: u32) -> Result<i16, <i16 as TryFrom<u32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<usize> for u16[src]

type Error = TryFromIntError

fn try_from(u: usize) -> Result<u16, <u16 as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for u32[src]

type Error = TryFromIntError

fn try_from(u: isize) -> Result<u32, <u32 as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u32> for char[src]

impl TryFrom<u128> for i64[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<i64, <i64 as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u16> for NonZeroU16[src]

Attempts to convert u16 to NonZeroU16.

impl TryFrom<u64> for u16[src]

type Error = TryFromIntError

fn try_from(u: u64) -> Result<u16, <u16 as TryFrom<u64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for u32[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<u32, <u32 as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u32> for u16[src]

type Error = TryFromIntError

fn try_from(u: u32) -> Result<u16, <u16 as TryFrom<u32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i128> for u32[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<u32, <u32 as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u32> for usize[src]

type Error = TryFromIntError

fn try_from(value: u32) -> Result<usize, <usize as TryFrom<u32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i32> for u64[src]

type Error = TryFromIntError

fn try_from(u: i32) -> Result<u64, <u64 as TryFrom<i32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u64> for isize[src]

type Error = TryFromIntError

fn try_from(u: u64) -> Result<isize, <isize as TryFrom<u64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i16> for i8[src]

type Error = TryFromIntError

fn try_from(u: i16) -> Result<i8, <i8 as TryFrom<i16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i64> for u32[src]

type Error = TryFromIntError

fn try_from(u: i64) -> Result<u32, <u32 as TryFrom<i64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for u16[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<u16, <u16 as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i32> for i8[src]

type Error = TryFromIntError

fn try_from(u: i32) -> Result<i8, <i8 as TryFrom<i32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u16> for isize[src]

type Error = TryFromIntError

fn try_from(value: u16) -> Result<isize, <isize as TryFrom<u16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u64> for u32[src]

type Error = TryFromIntError

fn try_from(u: u64) -> Result<u32, <u32 as TryFrom<u64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<usize> for i128[src]

type Error = TryFromIntError

fn try_from(value: usize) -> Result<i128, <i128 as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<usize> for i32[src]

type Error = TryFromIntError

fn try_from(u: usize) -> Result<i32, <i32 as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i16> for u32[src]

type Error = TryFromIntError

fn try_from(u: i16) -> Result<u32, <u32 as TryFrom<i16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N][src]

impl TryFrom<u16> for u8[src]

type Error = TryFromIntError

fn try_from(u: u16) -> Result<u8, <u8 as TryFrom<u16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for u8[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<u8, <u8 as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for i128[src]

type Error = TryFromIntError

fn try_from(value: isize) -> Result<i128, <i128 as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u64> for usize[src]

type Error = TryFromIntError

fn try_from(value: u64) -> Result<usize, <usize as TryFrom<u64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N][src]

impl TryFrom<i16> for u8[src]

type Error = TryFromIntError

fn try_from(u: i16) -> Result<u8, <u8 as TryFrom<i16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<usize> for u64[src]

type Error = TryFromIntError

fn try_from(value: usize) -> Result<u64, <u64 as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u64> for i32[src]

type Error = TryFromIntError

fn try_from(u: u64) -> Result<i32, <i32 as TryFrom<u64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<usize> for u32[src]

type Error = TryFromIntError

fn try_from(u: usize) -> Result<u32, <u32 as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u8> for i8[src]

type Error = TryFromIntError

fn try_from(u: u8) -> Result<i8, <i8 as TryFrom<u8>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i128> for NonZeroI128[src]

Attempts to convert i128 to NonZeroI128.

impl TryFrom<i8> for usize[src]

type Error = TryFromIntError

fn try_from(u: i8) -> Result<usize, <usize as TryFrom<i8>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i128> for i64[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<i64, <i64 as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i32> for u32[src]

type Error = TryFromIntError

fn try_from(u: i32) -> Result<u32, <u32 as TryFrom<i32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i64> for u16[src]

type Error = TryFromIntError

fn try_from(u: i64) -> Result<u16, <u16 as TryFrom<i64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u32> for isize[src]

type Error = TryFromIntError

fn try_from(value: u32) -> Result<isize, <isize as TryFrom<u32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for u128[src]

type Error = TryFromIntError

fn try_from(u: isize) -> Result<u128, <u128 as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u64> for NonZeroU64[src]

Attempts to convert u64 to NonZeroU64.

impl TryFrom<i32> for u128[src]

type Error = TryFromIntError

fn try_from(u: i32) -> Result<u128, <u128 as TryFrom<i32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i64> for usize[src]

type Error = TryFromIntError

fn try_from(u: i64) -> Result<usize, <usize as TryFrom<i64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i64> for i16[src]

type Error = TryFromIntError

fn try_from(u: i64) -> Result<i16, <i16 as TryFrom<i64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i8> for u32[src]

type Error = TryFromIntError

fn try_from(u: i8) -> Result<u32, <u32 as TryFrom<i8>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for NonZeroU128[src]

Attempts to convert u128 to NonZeroU128.

impl TryFrom<usize> for u128[src]

type Error = TryFromIntError

fn try_from(value: usize) -> Result<u128, <u128 as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i16> for NonZeroI16[src]

Attempts to convert i16 to NonZeroI16.

impl TryFrom<i8> for u16[src]

type Error = TryFromIntError

fn try_from(u: i8) -> Result<u16, <u16 as TryFrom<i8>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for i64[src]

type Error = TryFromIntError

fn try_from(value: isize) -> Result<i64, <i64 as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i32> for i16[src]

type Error = TryFromIntError

fn try_from(u: i32) -> Result<i16, <i16 as TryFrom<i32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i32> for u8[src]

type Error = TryFromIntError

fn try_from(u: i32) -> Result<u8, <u8 as TryFrom<i32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<usize> for isize[src]

type Error = TryFromIntError

fn try_from(u: usize) -> Result<isize, <isize as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i32> for NonZeroI32[src]

Attempts to convert i32 to NonZeroI32.

impl TryFrom<usize> for i64[src]

type Error = TryFromIntError

fn try_from(u: usize) -> Result<i64, <i64 as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u16> for i8[src]

type Error = TryFromIntError

fn try_from(u: u16) -> Result<i8, <i8 as TryFrom<u16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i64> for i8[src]

type Error = TryFromIntError

fn try_from(u: i64) -> Result<i8, <i8 as TryFrom<i64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i64> for i32[src]

type Error = TryFromIntError

fn try_from(u: i64) -> Result<i32, <i32 as TryFrom<i64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for usize[src]

type Error = TryFromIntError

fn try_from(u: isize) -> Result<usize, <usize as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u64> for i16[src]

type Error = TryFromIntError

fn try_from(u: u64) -> Result<i16, <i16 as TryFrom<u64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for i8[src]

type Error = TryFromIntError

fn try_from(u: isize) -> Result<i8, <i8 as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for u64[src]

type Error = TryFromIntError

fn try_from(u: isize) -> Result<u64, <u64 as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u16> for i16[src]

type Error = TryFromIntError

fn try_from(u: u16) -> Result<i16, <i16 as TryFrom<u16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i8> for u8[src]

type Error = TryFromIntError

fn try_from(u: i8) -> Result<u8, <u8 as TryFrom<i8>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i16> for u64[src]

type Error = TryFromIntError

fn try_from(u: i16) -> Result<u64, <u64 as TryFrom<i16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for i16[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<i16, <i16 as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i128> for i16[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<i16, <i16 as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i8> for NonZeroI8[src]

Attempts to convert i8 to NonZeroI8.

impl TryFrom<i8> for u128[src]

type Error = TryFromIntError

fn try_from(u: i8) -> Result<u128, <u128 as TryFrom<i8>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u32> for u8[src]

type Error = TryFromIntError

fn try_from(u: u32) -> Result<u8, <u8 as TryFrom<u32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i128> for u128[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<u128, <u128 as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u32> for NonZeroU32[src]

Attempts to convert u32 to NonZeroU32.

impl TryFrom<isize> for u16[src]

type Error = TryFromIntError

fn try_from(u: isize) -> Result<u16, <u16 as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i16> for u128[src]

type Error = TryFromIntError

fn try_from(u: i16) -> Result<u128, <u128 as TryFrom<i16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u32> for i8[src]

type Error = TryFromIntError

fn try_from(u: u32) -> Result<i8, <i8 as TryFrom<u32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i128> for u64[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<u64, <u64 as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i128> for u8[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<u8, <u8 as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for usize[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<usize, <usize as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for u64[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<u64, <u64 as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u64> for u8[src]

type Error = TryFromIntError

fn try_from(u: u64) -> Result<u8, <u8 as TryFrom<u64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i8> for u64[src]

type Error = TryFromIntError

fn try_from(u: i8) -> Result<u64, <u64 as TryFrom<i8>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i16> for usize[src]

type Error = TryFromIntError

fn try_from(u: i16) -> Result<usize, <usize as TryFrom<i16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for isize[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<isize, <isize as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for i8[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<i8, <i8 as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for i32[src]

type Error = TryFromIntError

fn try_from(u: isize) -> Result<i32, <i32 as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<usize> for NonZeroUsize[src]

Attempts to convert usize to NonZeroUsize.

impl TryFrom<i128> for i32[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<i32, <i32 as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for i32[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<i32, <i32 as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<u128> for i128[src]

type Error = TryFromIntError

fn try_from(u: u128) -> Result<i128, <i128 as TryFrom<u128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for u8[src]

type Error = TryFromIntError

fn try_from(u: isize) -> Result<u8, <u8 as TryFrom<isize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i16> for u16[src]

type Error = TryFromIntError

fn try_from(u: i16) -> Result<u16, <u16 as TryFrom<i16>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<isize> for NonZeroIsize[src]

Attempts to convert isize to NonZeroIsize.

impl TryFrom<usize> for i8[src]

type Error = TryFromIntError

fn try_from(u: usize) -> Result<i8, <i8 as TryFrom<usize>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i128> for u16[src]

type Error = TryFromIntError

fn try_from(u: i128) -> Result<u16, <u16 as TryFrom<i128>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i64> for u64[src]

type Error = TryFromIntError

fn try_from(u: i64) -> Result<u64, <u64 as TryFrom<i64>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl TryFrom<i32> for usize[src]

type Error = TryFromIntError

fn try_from(u: i32) -> Result<usize, <usize as TryFrom<i32>>::Error>[src]

Try to create the target number type from a source number type. This returns an error if the source value is outside of the range of the target type.

impl<T, const N: usize> TryFrom<Arc<[T]>> for Arc<[T; N]>[src]

type Error = Arc<[T]>

impl<T, const N: usize> TryFrom<Box<[T]>> for Box<[T; N]>[src]

type Error = Box<[T]>

impl<T, const N: usize> TryFrom<Rc<[T]>> for Rc<[T; N]>[src]

type Error = Rc<[T]>

impl TryFrom<TcpListener> for TcpListener[src]

type Error = Error

fn try_from(
    value: TcpListener
) -> Result<TcpListener, <TcpListener as TryFrom<TcpListener>>::Error>
[src]

Consumes value, returning the mio I/O object.

See PollEvented::into_inner for more details about resource deregistration that happens during the call.

impl TryFrom<UnixDatagram> for UnixDatagram[src]

type Error = Error

fn try_from(
    value: UnixDatagram
) -> Result<UnixDatagram, <UnixDatagram as TryFrom<UnixDatagram>>::Error>
[src]

Consumes value, returning the mio I/O object.

See PollEvented::into_inner for more details about resource deregistration that happens during the call.

impl TryFrom<UnixStream> for UnixStream[src]

type Error = Error

fn try_from(stream: UnixStream) -> Result<UnixStream, Error>[src]

Consumes stream, returning the tokio I/O object.

This is equivalent to UnixStream::from_std(stream).

impl TryFrom<UnixListener> for UnixListener[src]

type Error = Error

fn try_from(
    value: UnixListener
) -> Result<UnixListener, <UnixListener as TryFrom<UnixListener>>::Error>
[src]

Consumes value, returning the mio I/O object.

See PollEvented::into_inner for more details about resource deregistration that happens during the call.

impl TryFrom<TcpListener> for TcpListener[src]

type Error = Error

fn try_from(
    stream: TcpListener
) -> Result<TcpListener, <TcpListener as TryFrom<TcpListener>>::Error>
[src]

Consumes stream, returning the tokio I/O object.

This is equivalent to TcpListener::from_std(stream).

impl TryFrom<UdpSocket> for UdpSocket[src]

type Error = Error

fn try_from(
    value: UdpSocket
) -> Result<UdpSocket, <UdpSocket as TryFrom<UdpSocket>>::Error>
[src]

Consumes value, returning the mio I/O object.

See PollEvented::into_inner for more details about resource deregistration that happens during the call.

impl TryFrom<TcpStream> for TcpStream[src]

type Error = Error

fn try_from(
    value: TcpStream
) -> Result<TcpStream, <TcpStream as TryFrom<TcpStream>>::Error>
[src]

Consumes value, returning the mio I/O object.

See PollEvented::into_inner for more details about resource deregistration that happens during the call.

impl TryFrom<TcpStream> for TcpStream[src]

type Error = Error

fn try_from(
    stream: TcpStream
) -> Result<TcpStream, <TcpStream as TryFrom<TcpStream>>::Error>
[src]

Consumes stream, returning the tokio I/O object.

This is equivalent to TcpStream::from_std(stream).

impl TryFrom<UnixDatagram> for UnixDatagram[src]

type Error = Error

fn try_from(
    stream: UnixDatagram
) -> Result<UnixDatagram, <UnixDatagram as TryFrom<UnixDatagram>>::Error>
[src]

Consumes stream, returning the tokio I/O object.

This is equivalent to UnixDatagram::from_std(stream).

impl TryFrom<UnixStream> for UnixStream[src]

type Error = Error

fn try_from(
    value: UnixStream
) -> Result<UnixStream, <UnixStream as TryFrom<UnixStream>>::Error>
[src]

Consumes value, returning the mio I/O object.

See PollEvented::into_inner for more details about resource deregistration that happens during the call.

impl TryFrom<UdpSocket> for UdpSocket[src]

type Error = Error

fn try_from(
    stream: UdpSocket
) -> Result<UdpSocket, <UdpSocket as TryFrom<UdpSocket>>::Error>
[src]

Consumes stream, returning the tokio I/O object.

This is equivalent to UdpSocket::from_std(stream).

impl TryFrom<UnixListener> for UnixListener[src]

type Error = Error

fn try_from(stream: UnixListener) -> Result<UnixListener, Error>[src]

Consumes stream, returning the tokio I/O object.

This is equivalent to UnixListener::from_std(stream).

Loading content...

Implementors

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

Loading content...