Trait NumCast
trait NumCast: Sized + ToPrimitive
An interface for casting between machine scalars.
Required Methods
fn from<T: ToPrimitive>(n: T) -> Option<Self>Creates a number from another value that can be converted into a primitive via the
ToPrimitivetrait. If the source value cannot be represented by the target type, thenNoneis 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
i64with a very high magnitude might not be convertible to ani32. On the other hand, conversions with possible precision loss or truncation are admitted, like anf32with a decimal part to an integer type, or even a largef64saturating tof32infinity.
Implementors
impl NumCast for f32impl NumCast for u64impl NumCast for i32impl NumCast for f64impl NumCast for u128impl NumCast for i64impl<T: NumCast> NumCast for Wrapping<T>impl NumCast for u8impl NumCast for usizeimpl NumCast for i128impl NumCast for u16impl NumCast for i8impl NumCast for isizeimpl NumCast for u32impl NumCast for i16