Trait rin::math::cast::FromPrimitive[][src]

pub trait FromPrimitive {
Show methods pub fn from_i64(n: i64) -> Option<Self>;
pub fn from_u64(n: u64) -> Option<Self>; pub fn from_isize(n: isize) -> Option<Self> { ... }
pub fn from_i8(n: i8) -> Option<Self> { ... }
pub fn from_i16(n: i16) -> Option<Self> { ... }
pub fn from_i32(n: i32) -> Option<Self> { ... }
pub fn from_i128(n: i128) -> Option<Self> { ... }
pub fn from_usize(n: usize) -> Option<Self> { ... }
pub fn from_u8(n: u8) -> Option<Self> { ... }
pub fn from_u16(n: u16) -> Option<Self> { ... }
pub fn from_u32(n: u32) -> Option<Self> { ... }
pub fn from_u128(n: u128) -> Option<Self> { ... }
pub fn from_f32(n: f32) -> Option<Self> { ... }
pub fn from_f64(n: f64) -> Option<Self> { ... }
}

A generic trait for converting a number to a value.

A value can be represented by the target type when it lies within the range of scalars supported by the target type. For example, a negative integer cannot be represented by an unsigned integer type, and an i64 with a very high magnitude might not be convertible to an i32. On the other hand, conversions with possible precision loss or truncation are admitted, like an f32 with a decimal part to an integer type, or even a large f64 saturating to f32 infinity.

Required methods

pub fn from_i64(n: i64) -> Option<Self>[src]

Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

pub fn from_u64(n: u64) -> Option<Self>[src]

Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

Loading content...

Provided methods

pub fn from_isize(n: isize) -> Option<Self>[src]

Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

pub fn from_i8(n: i8) -> Option<Self>[src]

Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

pub fn from_i16(n: i16) -> Option<Self>[src]

Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

pub fn from_i32(n: i32) -> Option<Self>[src]

Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

pub fn from_i128(n: i128) -> Option<Self>[src]

Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

This method is only available with feature i128 enabled on Rust >= 1.26.

The default implementation converts through from_i64(). Types implementing this trait should override this method if they can represent a greater range.

pub fn from_usize(n: usize) -> Option<Self>[src]

Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

pub fn from_u8(n: u8) -> Option<Self>[src]

Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

pub fn from_u16(n: u16) -> Option<Self>[src]

Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

pub fn from_u32(n: u32) -> Option<Self>[src]

Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

pub fn from_u128(n: u128) -> Option<Self>[src]

Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

This method is only available with feature i128 enabled on Rust >= 1.26.

The default implementation converts through from_u64(). Types implementing this trait should override this method if they can represent a greater range.

pub fn from_f32(n: f32) -> Option<Self>[src]

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

pub fn from_f64(n: f64) -> Option<Self>[src]

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.

The default implementation tries to convert through from_i64(), and failing that through from_u64(). Types implementing this trait should override this method if they can represent a greater range.

Loading content...

Implementations on Foreign Types

impl FromPrimitive for isize[src]

impl FromPrimitive for u64[src]

impl FromPrimitive for i32[src]

impl FromPrimitive for f64[src]

impl FromPrimitive for u8[src]

impl FromPrimitive for i8[src]

impl FromPrimitive for f32[src]

impl<T> FromPrimitive for Wrapping<T> where
    T: FromPrimitive
[src]

impl FromPrimitive for i64[src]

impl FromPrimitive for i128[src]

impl FromPrimitive for u128[src]

impl FromPrimitive for usize[src]

impl FromPrimitive for u32[src]

impl FromPrimitive for i16[src]

impl FromPrimitive for u16[src]

impl FromPrimitive for Ratio<u128>[src]

impl FromPrimitive for Ratio<i32>[src]

impl FromPrimitive for Ratio<i64>[src]

impl FromPrimitive for Ratio<i8>[src]

impl FromPrimitive for Ratio<u16>[src]

impl FromPrimitive for Ratio<u8>[src]

impl FromPrimitive for Ratio<i128>[src]

impl FromPrimitive for Ratio<isize>[src]

impl FromPrimitive for Ratio<i16>[src]

impl FromPrimitive for Ratio<usize>[src]

impl FromPrimitive for Ratio<u32>[src]

impl FromPrimitive for Ratio<u64>[src]

impl FromPrimitive for Month[src]

pub fn from_u64(n: u64) -> Option<Month>[src]

Returns an Option from a i64, assuming a 1-index, January = 1.

Month::from_i64(n: i64): | 1 | 2 | … | 12 —————————| –––––––––– | ——————— | … | —– ``: | Some(Month::January) | Some(Month::February) | … | Some(Month::December)

impl FromPrimitive for Weekday[src]

Any weekday can be represented as an integer from 0 to 6, which equals to Weekday::num_days_from_monday in this implementation. Do not heavily depend on this though; use explicit methods whenever possible.

impl FromPrimitive for AutoSimd<[f32; 8]>[src]

impl FromPrimitive for AutoSimd<[i16; 2]>[src]

impl FromPrimitive for AutoSimd<[u128; 4]>[src]

impl FromPrimitive for AutoSimd<[f64; 8]>[src]

impl FromPrimitive for AutoSimd<[u16; 2]>[src]

impl FromPrimitive for AutoSimd<[i128; 4]>[src]

impl FromPrimitive for AutoSimd<[u128; 2]>[src]

impl FromPrimitive for AutoSimd<[i16; 8]>[src]

impl FromPrimitive for AutoSimd<[i16; 16]>[src]

impl FromPrimitive for AutoSimd<[isize; 8]>[src]

impl FromPrimitive for AutoSimd<[u16; 8]>[src]

impl FromPrimitive for AutoSimd<[i8; 2]>[src]

impl FromPrimitive for AutoSimd<[u64; 2]>[src]

impl FromPrimitive for AutoSimd<[i32; 4]>[src]

impl FromPrimitive for AutoSimd<[i8; 4]>[src]

impl FromPrimitive for AutoSimd<[i32; 16]>[src]

impl FromPrimitive for AutoSimd<[u64; 8]>[src]

impl FromPrimitive for AutoSimd<[f64; 4]>[src]

impl FromPrimitive for AutoSimd<[u16; 16]>[src]

impl FromPrimitive for AutoSimd<[f64; 2]>[src]

impl FromPrimitive for AutoSimd<[f32; 16]>[src]

impl FromPrimitive for AutoSimd<[u16; 32]>[src]

impl FromPrimitive for AutoSimd<[i8; 8]>[src]

impl FromPrimitive for AutoSimd<[u16; 4]>[src]

impl FromPrimitive for AutoSimd<[i32; 8]>[src]

impl FromPrimitive for AutoSimd<[i64; 4]>[src]

impl FromPrimitive for AutoSimd<[usize; 2]>[src]

impl FromPrimitive for AutoSimd<[u8; 32]>[src]

impl FromPrimitive for AutoSimd<[i8; 32]>[src]

impl FromPrimitive for AutoSimd<[u8; 4]>[src]

impl FromPrimitive for AutoSimd<[i64; 8]>[src]

impl FromPrimitive for AutoSimd<[i128; 1]>[src]

impl FromPrimitive for AutoSimd<[u32; 16]>[src]

impl FromPrimitive for AutoSimd<[isize; 4]>[src]

impl FromPrimitive for AutoSimd<[u128; 1]>[src]

impl FromPrimitive for AutoSimd<[usize; 8]>[src]

impl FromPrimitive for AutoSimd<[u32; 4]>[src]

impl FromPrimitive for AutoSimd<[u8; 2]>[src]

impl FromPrimitive for AutoSimd<[i8; 16]>[src]

impl FromPrimitive for AutoSimd<[i64; 2]>[src]

impl FromPrimitive for AutoSimd<[u8; 8]>[src]

impl FromPrimitive for AutoSimd<[usize; 4]>[src]

impl FromPrimitive for AutoSimd<[isize; 2]>[src]

impl FromPrimitive for AutoSimd<[f32; 4]>[src]

impl FromPrimitive for AutoSimd<[i16; 4]>[src]

impl FromPrimitive for AutoSimd<[i128; 2]>[src]

impl FromPrimitive for AutoSimd<[i32; 2]>[src]

impl FromPrimitive for AutoSimd<[i16; 32]>[src]

impl FromPrimitive for AutoSimd<[u32; 2]>[src]

impl FromPrimitive for AutoSimd<[u8; 16]>[src]

impl FromPrimitive for AutoSimd<[u64; 4]>[src]

impl FromPrimitive for AutoSimd<[u32; 8]>[src]

impl FromPrimitive for AutoSimd<[f32; 2]>[src]

impl<T> FromPrimitive for Complex<T> where
    T: FromPrimitive + Num
[src]

Loading content...

Implementors

impl FromPrimitive for rin::math::simd::AutoSimd<[f32; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[f32; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[f32; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[f32; 16]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[f64; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[f64; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[f64; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i8; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i8; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i8; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i8; 16]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i8; 32]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i16; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i16; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i16; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i16; 16]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i16; 32]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i32; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i32; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i32; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i32; 16]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i64; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i64; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i64; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i128; 1]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i128; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[i128; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[isize; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[isize; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[isize; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u8; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u8; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u8; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u8; 16]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u8; 32]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u16; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u16; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u16; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u16; 16]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u16; 32]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u32; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u32; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u32; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u32; 16]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u64; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u64; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u64; 8]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u128; 1]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u128; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[u128; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[usize; 2]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[usize; 4]>[src]

impl FromPrimitive for rin::math::simd::AutoSimd<[usize; 8]>[src]

impl<N> FromPrimitive for Deg<N> where
    N: FromPrimitive
[src]

impl<N> FromPrimitive for Rad<N> where
    N: FromPrimitive
[src]

impl<T> FromPrimitive for rin::math::Complex<T> where
    T: FromPrimitive + Num
[src]

Loading content...