Trait CastInto

Source
pub trait CastInto<T: Copy>: Copy {
    // Required methods
    fn cast(self) -> T;
    fn cast_lossy(self) -> T;
}
Expand description

Trait to express (possibly lossy) casting of integers

Required Methods§

Source

fn cast(self) -> T

By default, casts should be exact.

Source

fn cast_lossy(self) -> T

Call for casts that are expected to truncate.

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 CastInto<f32> for i8

Source§

fn cast(self) -> f32

Source§

fn cast_lossy(self) -> f32

Source§

impl CastInto<f32> for i16

Source§

fn cast(self) -> f32

Source§

fn cast_lossy(self) -> f32

Source§

impl CastInto<f32> for i32

Source§

fn cast(self) -> f32

Source§

fn cast_lossy(self) -> f32

Source§

impl CastInto<f32> for i64

Source§

fn cast(self) -> f32

Source§

fn cast_lossy(self) -> f32

Source§

impl CastInto<f32> for i128

Source§

fn cast(self) -> f32

Source§

fn cast_lossy(self) -> f32

Source§

impl CastInto<f64> for i8

Source§

fn cast(self) -> f64

Source§

fn cast_lossy(self) -> f64

Source§

impl CastInto<f64> for i16

Source§

fn cast(self) -> f64

Source§

fn cast_lossy(self) -> f64

Source§

impl CastInto<f64> for i32

Source§

fn cast(self) -> f64

Source§

fn cast_lossy(self) -> f64

Source§

impl CastInto<f64> for i64

Source§

fn cast(self) -> f64

Source§

fn cast_lossy(self) -> f64

Source§

impl CastInto<f64> for i128

Source§

fn cast(self) -> f64

Source§

fn cast_lossy(self) -> f64

Source§

impl CastInto<i8> for i8

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for i16

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for i32

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for i64

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for i128

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for isize

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for u8

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for u16

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for u32

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for u64

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for u128

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i8> for usize

Source§

fn cast(self) -> i8

Source§

fn cast_lossy(self) -> i8

Source§

impl CastInto<i16> for i8

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for i16

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for i32

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for i64

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for i128

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for isize

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for u8

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for u16

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for u32

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for u64

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for u128

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i16> for usize

Source§

fn cast(self) -> i16

Source§

fn cast_lossy(self) -> i16

Source§

impl CastInto<i32> for i8

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for i16

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for i32

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for i64

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for i128

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for isize

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for u8

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for u16

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for u32

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for u64

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for u128

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i32> for usize

Source§

fn cast(self) -> i32

Source§

fn cast_lossy(self) -> i32

Source§

impl CastInto<i64> for i8

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for i16

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for i32

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for i64

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for i128

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for isize

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for u8

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for u16

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for u32

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for u64

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for u128

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i64> for usize

Source§

fn cast(self) -> i64

Source§

fn cast_lossy(self) -> i64

Source§

impl CastInto<i128> for i8

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for i16

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for i32

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for i64

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for i128

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for isize

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for u8

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for u16

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for u32

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for u64

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for u128

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<i128> for usize

Source§

fn cast(self) -> i128

Source§

fn cast_lossy(self) -> i128

Source§

impl CastInto<isize> for i8

Source§

impl CastInto<isize> for i16

Source§

impl CastInto<isize> for i32

Source§

impl CastInto<isize> for i64

Source§

impl CastInto<isize> for i128

Source§

impl CastInto<isize> for isize

Source§

impl CastInto<isize> for u8

Source§

impl CastInto<isize> for u16

Source§

impl CastInto<isize> for u32

Source§

impl CastInto<isize> for u64

Source§

impl CastInto<isize> for u128

Source§

impl CastInto<isize> for usize

Source§

impl CastInto<u8> for i8

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for i16

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for i32

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for i64

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for i128

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for isize

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for u8

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for u16

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for u32

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for u64

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for u128

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u8> for usize

Source§

fn cast(self) -> u8

Source§

fn cast_lossy(self) -> u8

Source§

impl CastInto<u16> for i8

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for i16

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for i32

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for i64

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for i128

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for isize

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for u8

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for u16

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for u32

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for u64

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for u128

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u16> for usize

Source§

fn cast(self) -> u16

Source§

fn cast_lossy(self) -> u16

Source§

impl CastInto<u32> for i8

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for i16

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for i32

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for i64

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for i128

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for isize

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for u8

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for u16

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for u32

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for u64

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for u128

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u32> for usize

Source§

fn cast(self) -> u32

Source§

fn cast_lossy(self) -> u32

Source§

impl CastInto<u64> for i8

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for i16

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for i32

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for i64

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for i128

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for isize

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for u8

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for u16

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for u32

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for u64

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for u128

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u64> for usize

Source§

fn cast(self) -> u64

Source§

fn cast_lossy(self) -> u64

Source§

impl CastInto<u128> for i8

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for i16

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for i32

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for i64

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for i128

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for isize

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for u8

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for u16

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for u32

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for u64

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for u128

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<u128> for usize

Source§

fn cast(self) -> u128

Source§

fn cast_lossy(self) -> u128

Source§

impl CastInto<usize> for i8

Source§

impl CastInto<usize> for i16

Source§

impl CastInto<usize> for i32

Source§

impl CastInto<usize> for i64

Source§

impl CastInto<usize> for i128

Source§

impl CastInto<usize> for isize

Source§

impl CastInto<usize> for u8

Source§

impl CastInto<usize> for u16

Source§

impl CastInto<usize> for u32

Source§

impl CastInto<usize> for u64

Source§

impl CastInto<usize> for u128

Source§

impl CastInto<usize> for usize

Implementors§