Trait az::WrappingCast

source ·
pub trait WrappingCast<Dst> {
    // Required method
    fn wrapping_cast(self) -> Dst;
}
Expand description

Wrapping cast.

It is normally easier to use the WrappingAs trait instead of this trait.

Panics

This trait’s method panics if the value does not fit and cannot be wrapped, for example when trying to cast floating-point ∞ into an integer type.

Examples

use az::WrappingCast;
let a: u32 = (-1).wrapping_cast();
assert_eq!(a, u32::max_value());
assert_eq!(WrappingCast::<u8>::wrapping_cast(17.0 + 256.0), 17);

Required Methods§

source

fn wrapping_cast(self) -> Dst

Casts the value.

Implementations on Foreign Types§

source§

impl WrappingCast<u128> for i8

source§

impl WrappingCast<i128> for i16

source§

impl WrappingCast<u8> for u128

source§

impl WrappingCast<i64> for f32

source§

impl WrappingCast<u8> for isize

source§

impl WrappingCast<u64> for u32

source§

impl WrappingCast<u16> for i128

source§

impl WrappingCast<i8> for i64

source§

impl WrappingCast<usize> for i128

source§

impl WrappingCast<isize> for u8

source§

impl WrappingCast<i32> for i128

source§

impl WrappingCast<i16> for u8

source§

impl WrappingCast<isize> for i64

source§

impl WrappingCast<i128> for f64

source§

impl WrappingCast<i16> for f64

source§

impl WrappingCast<u64> for i64

source§

impl WrappingCast<u8> for i64

source§

impl WrappingCast<i16> for u64

source§

impl WrappingCast<i64> for u32

source§

impl WrappingCast<u64> for u8

source§

impl WrappingCast<u16> for f64

source§

impl WrappingCast<i32> for i16

source§

impl WrappingCast<u8> for i128

source§

impl WrappingCast<u32> for i128

source§

impl WrappingCast<u16> for i16

source§

impl WrappingCast<i64> for u128

source§

impl WrappingCast<u32> for f32

source§

impl WrappingCast<i32> for f32

source§

impl WrappingCast<u16> for i8

source§

impl WrappingCast<i16> for u32

source§

impl WrappingCast<i64> for i8

source§

impl WrappingCast<i32> for u64

source§

impl WrappingCast<u16> for u16

source§

impl WrappingCast<usize> for u8

source§

impl WrappingCast<i16> for i128

source§

impl WrappingCast<u16> for i32

source§

impl WrappingCast<i64> for i64

source§

impl WrappingCast<i16> for usize

source§

impl WrappingCast<i32> for u16

source§

impl WrappingCast<u128> for u32

source§

impl WrappingCast<u64> for isize

source§

impl WrappingCast<u128> for u8

source§

impl WrappingCast<i8> for f64

source§

impl WrappingCast<i128> for i8

source§

impl WrappingCast<u32> for i8

source§

impl WrappingCast<u16> for u8

source§

impl WrappingCast<i128> for u32

source§

impl WrappingCast<u64> for i8

source§

impl WrappingCast<usize> for i32

source§

impl WrappingCast<usize> for bool

source§

impl WrappingCast<i64> for i32

source§

impl WrappingCast<u16> for usize

source§

impl WrappingCast<u16> for f32

source§

impl WrappingCast<isize> for i128

source§

impl WrappingCast<u8> for u32

source§

impl WrappingCast<u128> for u16

source§

impl WrappingCast<i8> for u64

source§

impl WrappingCast<i128> for u64

source§

impl WrappingCast<i16> for bool

source§

impl WrappingCast<usize> for u64

source§

impl WrappingCast<i64> for u16

source§

impl WrappingCast<u32> for i16

source§

impl WrappingCast<i8> for u128

source§

impl WrappingCast<u8> for u64

source§

impl WrappingCast<usize> for i16

source§

impl WrappingCast<i16> for f32

source§

impl WrappingCast<u16> for i64

source§

impl WrappingCast<i32> for i64

source§

impl WrappingCast<u64> for u16

source§

impl WrappingCast<usize> for u16

source§

impl WrappingCast<u128> for f64

source§

impl WrappingCast<isize> for usize

source§

impl WrappingCast<u8> for u8

source§

impl WrappingCast<u32> for usize

source§

impl WrappingCast<isize> for f32

source§

impl WrappingCast<u128> for f32

source§

impl WrappingCast<u8> for usize

source§

impl WrappingCast<u128> for i128

source§

impl WrappingCast<usize> for usize

source§

impl WrappingCast<isize> for u128

source§

impl WrappingCast<u64> for bool

source§

impl WrappingCast<i128> for i128

source§

impl WrappingCast<i16> for i64

source§

impl WrappingCast<isize> for bool

source§

impl WrappingCast<u8> for i8

source§

impl WrappingCast<i64> for i16

source§

impl WrappingCast<i64> for i128

source§

impl WrappingCast<usize> for i8

source§

impl WrappingCast<usize> for u32

source§

impl WrappingCast<i8> for i16

source§

impl WrappingCast<u32> for u64

source§

impl WrappingCast<i128> for i64

source§

impl WrappingCast<i32> for u128

source§

impl WrappingCast<i8> for i128

source§

impl WrappingCast<usize> for f64

source§

impl WrappingCast<u128> for i64

source§

impl WrappingCast<u64> for i128

source§

impl WrappingCast<u32> for f64

source§

impl WrappingCast<usize> for f32

source§

impl WrappingCast<u16> for u32

source§

impl WrappingCast<isize> for u32

source§

impl WrappingCast<i128> for usize

source§

impl WrappingCast<u64> for i16

source§

impl WrappingCast<i8> for usize

source§

impl WrappingCast<u64> for u128

source§

impl WrappingCast<i16> for i8

source§

impl WrappingCast<u8> for u16

source§

impl WrappingCast<i8> for i32

source§

impl WrappingCast<usize> for u128

source§

impl WrappingCast<u16> for bool

source§

impl WrappingCast<u32> for i32

source§

impl WrappingCast<u32> for isize

source§

impl WrappingCast<u64> for i32

source§

impl WrappingCast<i32> for isize

source§

impl WrappingCast<i64> for isize

source§

impl WrappingCast<i128> for f32

source§

impl WrappingCast<u128> for isize

source§

impl WrappingCast<u128> for usize

source§

impl WrappingCast<i8> for bool

source§

impl WrappingCast<i8> for i8

source§

impl WrappingCast<u32> for u128

source§

impl WrappingCast<usize> for isize

source§

impl WrappingCast<i128> for u8

source§

impl WrappingCast<i32> for u8

source§

impl WrappingCast<u8> for f64

source§

impl WrappingCast<i16> for i16

source§

impl WrappingCast<u64> for f32

source§

impl WrappingCast<u8> for i32

source§

impl WrappingCast<u8> for bool

source§

impl WrappingCast<u16> for u64

source§

impl WrappingCast<i64> for f64

source§

impl WrappingCast<i128> for bool

source§

impl WrappingCast<isize> for u64

source§

impl WrappingCast<i8> for u32

source§

impl WrappingCast<isize> for i8

source§

impl WrappingCast<u32> for i64

source§

impl WrappingCast<i64> for u64

source§

impl WrappingCast<u64> for f64

source§

impl WrappingCast<i32> for bool

source§

impl WrappingCast<i32> for u32

source§

impl WrappingCast<isize> for isize

source§

impl WrappingCast<i8> for f32

source§

impl WrappingCast<i128> for u16

source§

impl WrappingCast<u32> for bool

source§

impl WrappingCast<i32> for i8

source§

impl WrappingCast<u128> for bool

source§

impl WrappingCast<i8> for u8

source§

impl WrappingCast<u16> for isize

source§

impl WrappingCast<i32> for usize

source§

impl WrappingCast<isize> for i32

source§

impl WrappingCast<u64> for usize

source§

impl WrappingCast<i128> for isize

source§

impl WrappingCast<u128> for u64

source§

impl WrappingCast<i32> for f64

source§

impl WrappingCast<i64> for bool

source§

impl WrappingCast<u32> for u16

source§

impl WrappingCast<u16> for u128

source§

impl WrappingCast<isize> for i16

source§

impl WrappingCast<i16> for isize

source§

impl WrappingCast<i128> for i32

source§

impl WrappingCast<u64> for u64

source§

impl WrappingCast<u128> for i32

source§

impl WrappingCast<u8> for f32

source§

impl WrappingCast<i128> for u128

source§

impl WrappingCast<u32> for u32

source§

impl WrappingCast<i16> for u16

source§

impl WrappingCast<u128> for u128

source§

impl WrappingCast<i16> for u128

source§

impl WrappingCast<usize> for i64

source§

impl WrappingCast<i64> for usize

source§

impl WrappingCast<isize> for f64

source§

impl WrappingCast<u8> for i16

source§

impl WrappingCast<u32> for u8

source§

impl WrappingCast<i64> for u8

source§

impl WrappingCast<i8> for u16

source§

impl WrappingCast<u128> for i16

source§

impl WrappingCast<i32> for i32

source§

impl WrappingCast<i8> for isize

source§

impl WrappingCast<isize> for u16

source§

impl WrappingCast<i16> for i32

Implementors§