BigCast

Trait BigCast 

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

Checked numeric casts up to and including i256 support.

This is meant as a more inclusive version of NumCast from the num-traits crate.

Required Methods§

Source

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

Cast the value n to Self using the relevant ToPrimitive method. If the value cannot be represented by Self, 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 BigCast for i8

Source§

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

Source§

impl BigCast for i16

Source§

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

Source§

impl BigCast for i32

Source§

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

Source§

impl BigCast for i64

Source§

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

Source§

impl BigCast for i128

Source§

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

Source§

impl BigCast for u8

Source§

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

Source§

impl BigCast for u16

Source§

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

Source§

impl BigCast for u32

Source§

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

Source§

impl BigCast for u64

Source§

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

Source§

impl BigCast for u128

Source§

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

Implementors§