Trait NumCast

Source
pub trait NumCast: Sized + ToPrimitive {
    // Required method
    fn from<T: ToPrimitive>(n: T) -> Option<Self>;
}
Expand description

An interface for casting between machine scalars.

Required Methods§

Source

fn from<T: ToPrimitive>(n: T) -> Option<Self>

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl NumCast for f32

Source§

impl NumCast for f64

Source§

impl NumCast for i8

Source§

impl NumCast for i16

Source§

impl NumCast for i32

Source§

impl NumCast for i64

Source§

impl NumCast for i128

Source§

impl NumCast for isize

Source§

impl NumCast for u8

Source§

impl NumCast for u16

Source§

impl NumCast for u32

Source§

impl NumCast for u64

Source§

impl NumCast for u128

Source§

impl NumCast for usize

Source§

impl<T: NumCast> NumCast for Wrapping<T>

Source§

fn from<U: ToPrimitive>(n: U) -> Option<Self>

Implementors§