Trait ndarray_rand::rand_distr::num_traits::NumCast [−][src]
An interface for casting between machine scalars.
Required methods
pub fn from<T>(n: T) -> Option<Self> where
T: ToPrimitive,
[src]
T: ToPrimitive,
Creates a number from another value that can be converted into
a primitive via the ToPrimitive
trait. If the source value cannot be
represented by the target type, then None
is returned.
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.
Implementations on Foreign Types
impl NumCast for u32
[src]
pub fn from<N>(n: N) -> Option<u32> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for i16
[src]
pub fn from<N>(n: N) -> Option<i16> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for u16
[src]
pub fn from<N>(n: N) -> Option<u16> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for u128
[src]
pub fn from<N>(n: N) -> Option<u128> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for i64
[src]
pub fn from<N>(n: N) -> Option<i64> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for f64
[src]
pub fn from<N>(n: N) -> Option<f64> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for usize
[src]
pub fn from<N>(n: N) -> Option<usize> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for u8
[src]
pub fn from<N>(n: N) -> Option<u8> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for f32
[src]
pub fn from<N>(n: N) -> Option<f32> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for i128
[src]
pub fn from<N>(n: N) -> Option<i128> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for i32
[src]
pub fn from<N>(n: N) -> Option<i32> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for isize
[src]
pub fn from<N>(n: N) -> Option<isize> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl<T> NumCast for Wrapping<T> where
T: NumCast,
[src]
T: NumCast,
pub fn from<U>(n: U) -> Option<Wrapping<T>> where
U: ToPrimitive,
[src]
U: ToPrimitive,
impl NumCast for u64
[src]
pub fn from<N>(n: N) -> Option<u64> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl NumCast for i8
[src]
pub fn from<N>(n: N) -> Option<i8> where
N: ToPrimitive,
[src]
N: ToPrimitive,
impl<T> NumCast for Complex<T> where
T: NumCast + Num,
[src]
T: NumCast + Num,
pub fn from<U>(n: U) -> Option<Complex<T>> where
U: ToPrimitive,
[src]
U: ToPrimitive,