enum_primitive::cast

Trait ToPrimitive

Source
pub trait ToPrimitive {
    // Required methods
    fn to_i64(&self) -> Option<i64>;
    fn to_u64(&self) -> Option<u64>;

    // Provided methods
    fn to_isize(&self) -> Option<isize> { ... }
    fn to_i8(&self) -> Option<i8> { ... }
    fn to_i16(&self) -> Option<i16> { ... }
    fn to_i32(&self) -> Option<i32> { ... }
    fn to_usize(&self) -> Option<usize> { ... }
    fn to_u8(&self) -> Option<u8> { ... }
    fn to_u16(&self) -> Option<u16> { ... }
    fn to_u32(&self) -> Option<u32> { ... }
}
Expand description

A generic trait for converting a value to a number.

Required Methods§

Source

fn to_i64(&self) -> Option<i64>

Converts the value of self to an i64.

Source

fn to_u64(&self) -> Option<u64>

Converts the value of self to an u64.

Provided Methods§

Source

fn to_isize(&self) -> Option<isize>

Converts the value of self to an isize.

Source

fn to_i8(&self) -> Option<i8>

Converts the value of self to an i8.

Source

fn to_i16(&self) -> Option<i16>

Converts the value of self to an i16.

Source

fn to_i32(&self) -> Option<i32>

Converts the value of self to an i32.

Source

fn to_usize(&self) -> Option<usize>

Converts the value of self to a usize.

Source

fn to_u8(&self) -> Option<u8>

Converts the value of self to an u8.

Source

fn to_u16(&self) -> Option<u16>

Converts the value of self to an u16.

Source

fn to_u32(&self) -> Option<u32>

Converts the value of self to an u32.

Implementations on Foreign Types§

Source§

impl ToPrimitive for i8

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Source§

impl ToPrimitive for i16

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Source§

impl ToPrimitive for i32

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Source§

impl ToPrimitive for i64

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Source§

impl ToPrimitive for isize

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Source§

impl ToPrimitive for u8

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Source§

impl ToPrimitive for u16

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Source§

impl ToPrimitive for u32

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Source§

impl ToPrimitive for u64

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Source§

impl ToPrimitive for usize

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Source§

impl<T: ToPrimitive> ToPrimitive for Wrapping<T>

Source§

fn to_isize(&self) -> Option<isize>

Source§

fn to_i8(&self) -> Option<i8>

Source§

fn to_i16(&self) -> Option<i16>

Source§

fn to_i32(&self) -> Option<i32>

Source§

fn to_i64(&self) -> Option<i64>

Source§

fn to_usize(&self) -> Option<usize>

Source§

fn to_u8(&self) -> Option<u8>

Source§

fn to_u16(&self) -> Option<u16>

Source§

fn to_u32(&self) -> Option<u32>

Source§

fn to_u64(&self) -> Option<u64>

Implementors§