Trait lnkit::prelude::TryFrom1.34.0[][src]

pub trait TryFrom<T> {
    type Error;
    pub 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[src]

The type returned in the event of a conversion error.

Loading content...

Required methods

pub fn try_from(value: T) -> Result<Self, Self::Error>[src]

Performs the conversion.

Loading content...

Implementations on Foreign Types

impl TryFrom<NonZeroI128> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroU8.

impl TryFrom<u128> for i32[src]

type Error = TryFromIntError

pub 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<NonZeroU32> for NonZeroUsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU32 to NonZeroUsize.

impl TryFrom<NonZeroI16> for NonZeroU64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI16 to NonZeroU64.

impl TryFrom<i16> for u32[src]

type Error = TryFromIntError

pub 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 TryFrom<NonZeroU64> for NonZeroU32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU64 to NonZeroU32.

impl TryFrom<NonZeroI32> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI32 to NonZeroI8.

impl TryFrom<i64> for u8[src]

type Error = TryFromIntError

pub 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<NonZeroI128> for NonZeroIsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroIsize.

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

impl TryFrom<u32> for NonZeroU32[src]

type Error = TryFromIntError

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

Attempts to convert u32 to NonZeroU32.

impl TryFrom<u64> for NonZeroU64[src]

type Error = TryFromIntError

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

Attempts to convert u64 to NonZeroU64.

impl TryFrom<isize> for NonZeroIsize[src]

type Error = TryFromIntError

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

Attempts to convert isize to NonZeroIsize.

impl TryFrom<usize> for i32[src]

type Error = TryFromIntError

pub 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<i8> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert i8 to NonZeroI8.

impl TryFrom<u32> for i32[src]

type Error = TryFromIntError

pub 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<NonZeroI8> for NonZeroU64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI8 to NonZeroU64.

impl TryFrom<usize> for u16[src]

type Error = TryFromIntError

pub 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<NonZeroIsize> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroI8.

impl TryFrom<NonZeroI32> for NonZeroUsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI32 to NonZeroUsize.

impl TryFrom<NonZeroU64> for NonZeroIsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU64 to NonZeroIsize.

impl TryFrom<NonZeroIsize> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroU8.

impl TryFrom<NonZeroI32> for NonZeroU32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI32 to NonZeroU32.

impl TryFrom<usize> for isize[src]

type Error = TryFromIntError

pub 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<NonZeroU128> for NonZeroI64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroI64.

impl TryFrom<i16> for u64[src]

type Error = TryFromIntError

pub 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<NonZeroI32> for NonZeroIsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI32 to NonZeroIsize.

impl TryFrom<NonZeroIsize> for NonZeroI128[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroI128.

impl TryFrom<i64> for usize[src]

type Error = TryFromIntError

pub 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<i128> for u64[src]

type Error = TryFromIntError

pub 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<u64> for usize[src]

type Error = TryFromIntError

pub fn try_from(u: 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 TryFrom<NonZeroU16> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU16 to NonZeroI8.

impl TryFrom<NonZeroU64> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU64 to NonZeroI8.

impl TryFrom<u16> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert u16 to NonZeroU16.

impl TryFrom<NonZeroU64> for NonZeroUsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU64 to NonZeroUsize.

impl TryFrom<NonZeroU128> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroU8.

impl TryFrom<i32> for u128[src]

type Error = TryFromIntError

pub 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 i16[src]

type Error = TryFromIntError

pub 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<usize> for u32[src]

type Error = TryFromIntError

pub fn try_from(value: 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<'_, T, const N: usize> TryFrom<&'_ [T]> for [T; N] where
    T: Copy
[src]

impl TryFrom<u32> for u8[src]

type Error = TryFromIntError

pub 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<u128> for u32[src]

type Error = TryFromIntError

pub 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<i64> for u128[src]

type Error = TryFromIntError

pub 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 TryFrom<u32> for i8[src]

type Error = TryFromIntError

pub 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<isize> for i128[src]

type Error = TryFromIntError

pub 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<NonZeroIsize> for NonZeroU32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroU32.

impl TryFrom<i16> for u16[src]

type Error = TryFromIntError

pub 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<NonZeroUsize> for NonZeroI32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroI32.

impl TryFrom<NonZeroI16> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI16 to NonZeroU8.

impl TryFrom<NonZeroI32> for NonZeroI16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI32 to NonZeroI16.

impl TryFrom<u64> for u16[src]

type Error = TryFromIntError

pub 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<i32> for isize[src]

type Error = TryFromIntError

pub 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<isize> for i16[src]

type Error = TryFromIntError

pub 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<NonZeroI128> for NonZeroI64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroI64.

impl TryFrom<NonZeroUsize> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroI8.

impl TryFrom<u128> for u16[src]

type Error = TryFromIntError

pub 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<NonZeroU128> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroI8.

impl TryFrom<NonZeroUsize> for NonZeroI16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroI16.

impl TryFrom<NonZeroU64> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU64 to NonZeroU8.

impl TryFrom<NonZeroUsize> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroU8.

impl TryFrom<NonZeroI64> for NonZeroI32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI64 to NonZeroI32.

impl TryFrom<u16> for isize[src]

type Error = TryFromIntError

pub 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<NonZeroIsize> for NonZeroI64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroI64.

impl TryFrom<i128> for usize[src]

type Error = TryFromIntError

pub 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<i8> for u128[src]

type Error = TryFromIntError

pub 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<i16> for i8[src]

type Error = TryFromIntError

pub 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<u64> for i8[src]

type Error = TryFromIntError

pub 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<i32> for i8[src]

type Error = TryFromIntError

pub 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<i32> for u64[src]

type Error = TryFromIntError

pub 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<NonZeroU64> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU64 to NonZeroU16.

impl TryFrom<NonZeroU32> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU32 to NonZeroU16.

impl TryFrom<u32> for isize[src]

type Error = TryFromIntError

pub fn try_from(u: 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<NonZeroU32> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU32 to NonZeroI8.

impl TryFrom<i32> for NonZeroI32[src]

type Error = TryFromIntError

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

Attempts to convert i32 to NonZeroI32.

impl TryFrom<NonZeroUsize> for NonZeroU32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroU32.

impl TryFrom<NonZeroU64> for NonZeroI64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU64 to NonZeroI64.

impl TryFrom<NonZeroI128> for NonZeroI32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroI32.

impl TryFrom<i128> for u32[src]

type Error = TryFromIntError

pub 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<NonZeroI64> for NonZeroU32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI64 to NonZeroU32.

impl TryFrom<i32> for u32[src]

type Error = TryFromIntError

pub 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<u128> for u8[src]

type Error = TryFromIntError

pub 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<u16> for i16[src]

type Error = TryFromIntError

pub 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<i128> for u128[src]

type Error = TryFromIntError

pub 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<isize> for u8[src]

type Error = TryFromIntError

pub 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<NonZeroIsize> for NonZeroU64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroU64.

impl TryFrom<NonZeroIsize> for NonZeroI32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroI32.

impl TryFrom<NonZeroI128> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroU16.

impl TryFrom<NonZeroIsize> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroU16.

impl TryFrom<NonZeroI32> for NonZeroU64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI32 to NonZeroU64.

impl TryFrom<i32> for u8[src]

type Error = TryFromIntError

pub 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<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N][src]

impl TryFrom<i32> for usize[src]

type Error = TryFromIntError

pub 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 TryFrom<i128> for u16[src]

type Error = TryFromIntError

pub 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<i8> for u64[src]

type Error = TryFromIntError

pub 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<u64> for i32[src]

type Error = TryFromIntError

pub 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<NonZeroU32> for NonZeroIsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU32 to NonZeroIsize.

impl TryFrom<NonZeroI128> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroI8.

impl TryFrom<NonZeroUsize> for NonZeroU64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroU64.

impl TryFrom<i64> for u32[src]

type Error = TryFromIntError

pub 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<NonZeroU32> for NonZeroI32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU32 to NonZeroI32.

impl TryFrom<usize> for i16[src]

type Error = TryFromIntError

pub 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<NonZeroI64> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI64 to NonZeroI8.

impl TryFrom<u8> for i8[src]

type Error = TryFromIntError

pub 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<u64> for u8[src]

type Error = TryFromIntError

pub 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<u64> for u32[src]

type Error = TryFromIntError

pub 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 i64[src]

type Error = TryFromIntError

pub fn try_from(value: 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<u128> for i16[src]

type Error = TryFromIntError

pub 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<i64> for i32[src]

type Error = TryFromIntError

pub 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<i32> for i16[src]

type Error = TryFromIntError

pub 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<NonZeroI32> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI32 to NonZeroU8.

impl TryFrom<i16> for NonZeroI16[src]

type Error = TryFromIntError

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

Attempts to convert i16 to NonZeroI16.

impl TryFrom<NonZeroI32> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI32 to NonZeroU16.

impl TryFrom<i128> for u8[src]

type Error = TryFromIntError

pub 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<NonZeroI16> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI16 to NonZeroI8.

impl TryFrom<i64> for u64[src]

type Error = TryFromIntError

pub 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<NonZeroUsize> for NonZeroIsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroIsize.

impl TryFrom<NonZeroI8> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI8 to NonZeroU8.

impl TryFrom<u32> for char[src]

impl TryFrom<NonZeroI64> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI64 to NonZeroU8.

impl TryFrom<i128> for i64[src]

type Error = TryFromIntError

pub 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<i128> for i8[src]

type Error = TryFromIntError

pub 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<i8> for u16[src]

type Error = TryFromIntError

pub 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 u128[src]

type Error = TryFromIntError

pub 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<NonZeroU128> for NonZeroI16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroI16.

impl TryFrom<isize> for i32[src]

type Error = TryFromIntError

pub fn try_from(value: 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<NonZeroI8> for NonZeroU128[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI8 to NonZeroU128.

impl TryFrom<u32> for i16[src]

type Error = TryFromIntError

pub 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<i8> for u32[src]

type Error = TryFromIntError

pub 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<NonZeroU128> for NonZeroU64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroU64.

impl TryFrom<NonZeroIsize> for NonZeroI16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroI16.

impl TryFrom<NonZeroI16> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI16 to NonZeroU16.

impl TryFrom<u16> for i8[src]

type Error = TryFromIntError

pub 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<usize> for i128[src]

type Error = TryFromIntError

pub 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<i64> for isize[src]

type Error = TryFromIntError

pub fn try_from(u: 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<u128> for i8[src]

type Error = TryFromIntError

pub 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<NonZeroI16> for NonZeroU32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI16 to NonZeroU32.

impl TryFrom<isize> for i8[src]

type Error = TryFromIntError

pub 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<usize> for i8[src]

type Error = TryFromIntError

pub 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<isize> for u32[src]

type Error = TryFromIntError

pub 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<isize> for usize[src]

type Error = TryFromIntError

pub 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<NonZeroI64> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI64 to NonZeroU16.

impl TryFrom<NonZeroU128> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroU16.

impl TryFrom<i16> for u8[src]

type Error = TryFromIntError

pub 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<isize> for u16[src]

type Error = TryFromIntError

pub 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<NonZeroU64> for NonZeroI16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU64 to NonZeroI16.

impl TryFrom<NonZeroI128> for NonZeroU128[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroU128.

impl TryFrom<u64> for i16[src]

type Error = TryFromIntError

pub 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<NonZeroU128> for NonZeroU32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroU32.

impl TryFrom<NonZeroU128> for NonZeroIsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroIsize.

impl TryFrom<i16> for usize[src]

type Error = TryFromIntError

pub 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<NonZeroI128> for NonZeroUsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroUsize.

impl TryFrom<usize> for u128[src]

type Error = TryFromIntError

pub 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<NonZeroI128> for NonZeroU64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroU64.

impl TryFrom<u16> for u8[src]

type Error = TryFromIntError

pub 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 i64[src]

type Error = TryFromIntError

pub 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<NonZeroU8> for NonZeroI8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU8 to NonZeroI8.

impl TryFrom<NonZeroU16> for NonZeroI16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU16 to NonZeroI16.

impl TryFrom<i64> for NonZeroI64[src]

type Error = TryFromIntError

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

Attempts to convert i64 to NonZeroI64.

impl TryFrom<i128> for i32[src]

type Error = TryFromIntError

pub 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<NonZeroU32> for NonZeroI16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU32 to NonZeroI16.

impl TryFrom<u128> for i128[src]

type Error = TryFromIntError

pub 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<i128> for i16[src]

type Error = TryFromIntError

pub 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 u8[src]

type Error = TryFromIntError

pub 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<NonZeroI16> for NonZeroUsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI16 to NonZeroUsize.

impl TryFrom<u32> for u16[src]

type Error = TryFromIntError

pub 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<usize> for NonZeroUsize[src]

type Error = TryFromIntError

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

Attempts to convert usize to NonZeroUsize.

impl TryFrom<isize> for i64[src]

type Error = TryFromIntError

pub 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<NonZeroI64> for NonZeroIsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI64 to NonZeroIsize.

impl TryFrom<NonZeroI128> for NonZeroU32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroU32.

impl TryFrom<NonZeroI8> for NonZeroUsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI8 to NonZeroUsize.

impl TryFrom<u32> for usize[src]

type Error = TryFromIntError

pub 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<NonZeroI64> for NonZeroU128[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI64 to NonZeroU128.

impl TryFrom<NonZeroUsize> for NonZeroI128[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroI128.

impl TryFrom<u128> for usize[src]

type Error = TryFromIntError

pub 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<i128> for isize[src]

type Error = TryFromIntError

pub 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<NonZeroI8> for NonZeroU32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI8 to NonZeroU32.

impl TryFrom<NonZeroIsize> for NonZeroU128[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroU128.

impl TryFrom<u64> for i64[src]

type Error = TryFromIntError

pub 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<NonZeroI16> for NonZeroU128[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI16 to NonZeroU128.

impl TryFrom<NonZeroI64> for NonZeroUsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI64 to NonZeroUsize.

impl TryFrom<i8> for usize[src]

type Error = TryFromIntError

pub 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<NonZeroU128> for NonZeroI32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroI32.

impl TryFrom<u8> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert u8 to NonZeroU8.

impl TryFrom<u128> for isize[src]

type Error = TryFromIntError

pub 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<isize> for u64[src]

type Error = TryFromIntError

pub 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<NonZeroI8> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI8 to NonZeroU16.

impl TryFrom<NonZeroU128> for NonZeroI128[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroI128.

impl TryFrom<NonZeroI64> for NonZeroU64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI64 to NonZeroU64.

impl TryFrom<i128> for NonZeroI128[src]

type Error = TryFromIntError

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

Attempts to convert i128 to NonZeroI128.

impl TryFrom<NonZeroUsize> for NonZeroU16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroU16.

impl TryFrom<u128> for NonZeroU128[src]

type Error = TryFromIntError

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

Attempts to convert u128 to NonZeroU128.

impl TryFrom<NonZeroU32> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU32 to NonZeroU8.

impl TryFrom<NonZeroI64> for NonZeroI16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI64 to NonZeroI16.

impl TryFrom<i16> for u128[src]

type Error = TryFromIntError

pub 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<NonZeroU128> for NonZeroUsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU128 to NonZeroUsize.

impl TryFrom<NonZeroI32> for NonZeroU128[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI32 to NonZeroU128.

impl TryFrom<NonZeroUsize> for NonZeroI64[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroI64.

impl TryFrom<NonZeroU16> for NonZeroU8[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU16 to NonZeroU8.

impl TryFrom<NonZeroIsize> for NonZeroUsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroIsize to NonZeroUsize.

impl TryFrom<NonZeroI128> for NonZeroI16[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroI128 to NonZeroI16.

impl TryFrom<u128> for u64[src]

type Error = TryFromIntError

pub 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<NonZeroUsize> for NonZeroU128[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroUsize to NonZeroU128.

impl TryFrom<i64> for i8[src]

type Error = TryFromIntError

pub 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<usize> for u8[src]

type Error = TryFromIntError

pub 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<NonZeroU16> for NonZeroIsize[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU16 to NonZeroIsize.

impl TryFrom<NonZeroU64> for NonZeroI32[src]

type Error = TryFromIntError

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

Attempts to convert NonZeroU64 to NonZeroI32.

impl TryFrom<usize> for u64[src]

type Error = TryFromIntError

pub 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 isize[src]

type Error = TryFromIntError

pub 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<i64> for u16[src]

type Error = TryFromIntError

pub 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<i32> for u16[src]

type Error = TryFromIntError

pub 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<T, const N: usize> TryFrom<Arc<[T]>> for Arc<[T; N]>[src]

type Error = Arc<[T]>

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

type Error = Box<[T], Global>

impl<T, A, const N: usize> TryFrom<Vec<T, A>> for [T; N] where
    A: Allocator
[src]

type Error = Vec<T, A>

pub fn try_from(vec: Vec<T, A>) -> Result<[T; N], Vec<T, A>>[src]

Gets the entire contents of the Vec<T> as an array, if its size exactly matches that of the requested array.

Examples

use std::convert::TryInto;
assert_eq!(vec![1, 2, 3].try_into(), Ok([1, 2, 3]));
assert_eq!(<Vec<i32>>::new().try_into(), Ok([]));

If the length doesn’t match, the input comes back in Err:

use std::convert::TryInto;
let r: Result<[i32; 4], _> = (0..10).collect::<Vec<_>>().try_into();
assert_eq!(r, Err(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]));

If you’re fine with just getting a prefix of the Vec<T>, you can call .truncate(N) first.

use std::convert::TryInto;
let mut v = String::from("hello world").into_bytes();
v.sort();
v.truncate(2);
let [a, b]: [_; 2] = v.try_into().unwrap();
assert_eq!(a, b' ');
assert_eq!(b, b'd');

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

type Error = Rc<[T]>

impl TryFrom<Duration> for Duration

type Error = ConversionRange

impl TryFrom<Duration> for Duration

type Error = ConversionRange

impl TryFrom<UnixListener> for Async<UnixListener>

type Error = Error

impl TryFrom<UnixDatagram> for Async<UnixDatagram>

type Error = Error

impl TryFrom<UnixStream> for Async<UnixStream>

type Error = Error

impl TryFrom<UdpSocket> for Async<UdpSocket>

type Error = Error

impl TryFrom<TcpStream> for Async<TcpStream>

type Error = Error

impl TryFrom<TcpListener> for Async<TcpListener>

type Error = Error

impl<'a> TryFrom<&'a str> for Uri[src]

type Error = InvalidUri

impl<'a> TryFrom<&'a String> for Uri[src]

type Error = InvalidUri

impl<'a> TryFrom<&'a str> for HeaderName[src]

type Error = InvalidHeaderName

impl TryFrom<Vec<u8, Global>> for HeaderValue[src]

impl TryFrom<u16> for StatusCode[src]

impl<'a> TryFrom<&'a String> for HeaderName[src]

impl<'a> TryFrom<&'a [u8]> for PathAndQuery[src]

impl<'a> TryFrom<&'a [u8]> for Authority[src]

impl<'a> TryFrom<&'a str> for HeaderValue[src]

impl TryFrom<String> for HeaderValue[src]

impl TryFrom<String> for PathAndQuery[src]

impl TryFrom<String> for Uri[src]

impl<'a> TryFrom<&'a String> for HeaderValue[src]

impl<'a> TryFrom<&'a [u8]> for StatusCode[src]

impl<'a> TryFrom<&'a [u8]> for Uri[src]

impl<'a> TryFrom<&'a str> for PathAndQuery[src]

type Error = InvalidUri

impl<'a> TryFrom<&'a [u8]> for Method[src]

impl<'a> TryFrom<&'a [u8]> for HeaderValue[src]

impl<'a> TryFrom<&'a [u8]> for HeaderName[src]

impl<'a, K, V, T> TryFrom<&'a HashMap<K, V, RandomState>> for HeaderMap<T> where
    T: TryFrom<&'a V>,
    K: Eq + Hash,
    HeaderName: TryFrom<&'a K>,
    <HeaderName as TryFrom<&'a K>>::Error: Into<Error>,
    <T as TryFrom<&'a V>>::Error: Into<Error>, 
[src]

Try to convert a HashMap into a HeaderMap.

Examples

use std::collections::HashMap;
use std::convert::TryInto;
use http::HeaderMap;

let mut map = HashMap::new();
map.insert("X-Custom-Header".to_string(), "my value".to_string());

let headers: HeaderMap = (&map).try_into().expect("valid headers");
assert_eq!(headers["X-Custom-Header"], "my value");

type Error = Error

impl<'a> TryFrom<&'a str> for Method[src]

type Error = InvalidMethod

impl<'a> TryFrom<&'a str> for StatusCode[src]

type Error = InvalidStatusCode

impl<'a> TryFrom<&'a str> for Scheme[src]

type Error = InvalidUri

impl<'a> TryFrom<&'a Uri> for Uri[src]

type Error = Error

impl<'a> TryFrom<&'a [u8]> for Scheme[src]

impl<'a> TryFrom<&'a str> for Authority[src]

type Error = InvalidUri

impl<'_> TryFrom<&'_ String> for PathAndQuery[src]

impl TryFrom<Parts> for Uri[src]

impl<'a> TryFrom<&'a str> for Url[src]

type Error = ParseError

impl<'_, T, A> TryFrom<&'_ [T]> for ArrayVec<A> where
    T: Clone + Default,
    A: Array<Item = T>, 

type Error = TryFromSliceError

#[must_use]
pub fn try_from(
    slice: &[T]
) -> Result<ArrayVec<A>, <ArrayVec<A> as TryFrom<&'_ [T]>>::Error>

The output has a length equal to that of the slice, with the same capacity as A.

Loading content...

Implementors

impl<T> TryFrom<&'_ ServerMessage<T>> for Message where
    T: Serialize
[src]

type Error = Error

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

type Error = Infallible

Loading content...