Trait az::SaturatingCast[][src]

pub trait SaturatingCast<Dst> {
    fn saturating_cast(self) -> Dst;
}

Used to cast into the destination type, saturating if the value does not fit.

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

Panics

This trait’s method panics if the value does not fit and saturation does not make sense, for example when trying to cast floating-point NaN into an integer type.

Examples

use az::SaturatingCast;
let a: u32 = (-1).saturating_cast();
assert_eq!(a, 0);
assert_eq!(SaturatingCast::<u8>::saturating_cast(17.0 + 256.0), 255);

Required methods

fn saturating_cast(self) -> Dst[src]

Casts the value.

Loading content...

Implementors

impl SaturatingCast<i8> for Round<f32>[src]

impl SaturatingCast<i8> for Round<f64>[src]

impl SaturatingCast<i8> for bool[src]

impl SaturatingCast<i8> for f32[src]

impl SaturatingCast<i8> for f64[src]

impl SaturatingCast<i8> for i8[src]

impl SaturatingCast<i8> for i16[src]

impl SaturatingCast<i8> for i32[src]

impl SaturatingCast<i8> for i64[src]

impl SaturatingCast<i8> for i128[src]

impl SaturatingCast<i8> for isize[src]

impl SaturatingCast<i8> for u8[src]

impl SaturatingCast<i8> for u16[src]

impl SaturatingCast<i8> for u32[src]

impl SaturatingCast<i8> for u64[src]

impl SaturatingCast<i8> for u128[src]

impl SaturatingCast<i8> for usize[src]

impl SaturatingCast<i16> for Round<f32>[src]

impl SaturatingCast<i16> for Round<f64>[src]

impl SaturatingCast<i16> for bool[src]

impl SaturatingCast<i16> for f32[src]

impl SaturatingCast<i16> for f64[src]

impl SaturatingCast<i16> for i8[src]

impl SaturatingCast<i16> for i16[src]

impl SaturatingCast<i16> for i32[src]

impl SaturatingCast<i16> for i64[src]

impl SaturatingCast<i16> for i128[src]

impl SaturatingCast<i16> for isize[src]

impl SaturatingCast<i16> for u8[src]

impl SaturatingCast<i16> for u16[src]

impl SaturatingCast<i16> for u32[src]

impl SaturatingCast<i16> for u64[src]

impl SaturatingCast<i16> for u128[src]

impl SaturatingCast<i16> for usize[src]

impl SaturatingCast<i32> for Round<f32>[src]

impl SaturatingCast<i32> for Round<f64>[src]

impl SaturatingCast<i32> for bool[src]

impl SaturatingCast<i32> for f32[src]

impl SaturatingCast<i32> for f64[src]

impl SaturatingCast<i32> for i8[src]

impl SaturatingCast<i32> for i16[src]

impl SaturatingCast<i32> for i32[src]

impl SaturatingCast<i32> for i64[src]

impl SaturatingCast<i32> for i128[src]

impl SaturatingCast<i32> for isize[src]

impl SaturatingCast<i32> for u8[src]

impl SaturatingCast<i32> for u16[src]

impl SaturatingCast<i32> for u32[src]

impl SaturatingCast<i32> for u64[src]

impl SaturatingCast<i32> for u128[src]

impl SaturatingCast<i32> for usize[src]

impl SaturatingCast<i64> for Round<f32>[src]

impl SaturatingCast<i64> for Round<f64>[src]

impl SaturatingCast<i64> for bool[src]

impl SaturatingCast<i64> for f32[src]

impl SaturatingCast<i64> for f64[src]

impl SaturatingCast<i64> for i8[src]

impl SaturatingCast<i64> for i16[src]

impl SaturatingCast<i64> for i32[src]

impl SaturatingCast<i64> for i64[src]

impl SaturatingCast<i64> for i128[src]

impl SaturatingCast<i64> for isize[src]

impl SaturatingCast<i64> for u8[src]

impl SaturatingCast<i64> for u16[src]

impl SaturatingCast<i64> for u32[src]

impl SaturatingCast<i64> for u64[src]

impl SaturatingCast<i64> for u128[src]

impl SaturatingCast<i64> for usize[src]

impl SaturatingCast<i128> for Round<f32>[src]

impl SaturatingCast<i128> for Round<f64>[src]

impl SaturatingCast<i128> for bool[src]

impl SaturatingCast<i128> for f32[src]

impl SaturatingCast<i128> for f64[src]

impl SaturatingCast<i128> for i8[src]

impl SaturatingCast<i128> for i16[src]

impl SaturatingCast<i128> for i32[src]

impl SaturatingCast<i128> for i64[src]

impl SaturatingCast<i128> for i128[src]

impl SaturatingCast<i128> for isize[src]

impl SaturatingCast<i128> for u8[src]

impl SaturatingCast<i128> for u16[src]

impl SaturatingCast<i128> for u32[src]

impl SaturatingCast<i128> for u64[src]

impl SaturatingCast<i128> for u128[src]

impl SaturatingCast<i128> for usize[src]

impl SaturatingCast<isize> for Round<f32>[src]

impl SaturatingCast<isize> for Round<f64>[src]

impl SaturatingCast<isize> for bool[src]

impl SaturatingCast<isize> for f32[src]

impl SaturatingCast<isize> for f64[src]

impl SaturatingCast<isize> for i8[src]

impl SaturatingCast<isize> for i16[src]

impl SaturatingCast<isize> for i32[src]

impl SaturatingCast<isize> for i64[src]

impl SaturatingCast<isize> for i128[src]

impl SaturatingCast<isize> for isize[src]

impl SaturatingCast<isize> for u8[src]

impl SaturatingCast<isize> for u16[src]

impl SaturatingCast<isize> for u32[src]

impl SaturatingCast<isize> for u64[src]

impl SaturatingCast<isize> for u128[src]

impl SaturatingCast<isize> for usize[src]

impl SaturatingCast<u8> for Round<f32>[src]

impl SaturatingCast<u8> for Round<f64>[src]

impl SaturatingCast<u8> for bool[src]

impl SaturatingCast<u8> for f32[src]

impl SaturatingCast<u8> for f64[src]

impl SaturatingCast<u8> for i8[src]

impl SaturatingCast<u8> for i16[src]

impl SaturatingCast<u8> for i32[src]

impl SaturatingCast<u8> for i64[src]

impl SaturatingCast<u8> for i128[src]

impl SaturatingCast<u8> for isize[src]

impl SaturatingCast<u8> for u8[src]

impl SaturatingCast<u8> for u16[src]

impl SaturatingCast<u8> for u32[src]

impl SaturatingCast<u8> for u64[src]

impl SaturatingCast<u8> for u128[src]

impl SaturatingCast<u8> for usize[src]

impl SaturatingCast<u16> for Round<f32>[src]

impl SaturatingCast<u16> for Round<f64>[src]

impl SaturatingCast<u16> for bool[src]

impl SaturatingCast<u16> for f32[src]

impl SaturatingCast<u16> for f64[src]

impl SaturatingCast<u16> for i8[src]

impl SaturatingCast<u16> for i16[src]

impl SaturatingCast<u16> for i32[src]

impl SaturatingCast<u16> for i64[src]

impl SaturatingCast<u16> for i128[src]

impl SaturatingCast<u16> for isize[src]

impl SaturatingCast<u16> for u8[src]

impl SaturatingCast<u16> for u16[src]

impl SaturatingCast<u16> for u32[src]

impl SaturatingCast<u16> for u64[src]

impl SaturatingCast<u16> for u128[src]

impl SaturatingCast<u16> for usize[src]

impl SaturatingCast<u32> for Round<f32>[src]

impl SaturatingCast<u32> for Round<f64>[src]

impl SaturatingCast<u32> for bool[src]

impl SaturatingCast<u32> for f32[src]

impl SaturatingCast<u32> for f64[src]

impl SaturatingCast<u32> for i8[src]

impl SaturatingCast<u32> for i16[src]

impl SaturatingCast<u32> for i32[src]

impl SaturatingCast<u32> for i64[src]

impl SaturatingCast<u32> for i128[src]

impl SaturatingCast<u32> for isize[src]

impl SaturatingCast<u32> for u8[src]

impl SaturatingCast<u32> for u16[src]

impl SaturatingCast<u32> for u32[src]

impl SaturatingCast<u32> for u64[src]

impl SaturatingCast<u32> for u128[src]

impl SaturatingCast<u32> for usize[src]

impl SaturatingCast<u64> for Round<f32>[src]

impl SaturatingCast<u64> for Round<f64>[src]

impl SaturatingCast<u64> for bool[src]

impl SaturatingCast<u64> for f32[src]

impl SaturatingCast<u64> for f64[src]

impl SaturatingCast<u64> for i8[src]

impl SaturatingCast<u64> for i16[src]

impl SaturatingCast<u64> for i32[src]

impl SaturatingCast<u64> for i64[src]

impl SaturatingCast<u64> for i128[src]

impl SaturatingCast<u64> for isize[src]

impl SaturatingCast<u64> for u8[src]

impl SaturatingCast<u64> for u16[src]

impl SaturatingCast<u64> for u32[src]

impl SaturatingCast<u64> for u64[src]

impl SaturatingCast<u64> for u128[src]

impl SaturatingCast<u64> for usize[src]

impl SaturatingCast<u128> for Round<f32>[src]

impl SaturatingCast<u128> for Round<f64>[src]

impl SaturatingCast<u128> for bool[src]

impl SaturatingCast<u128> for f32[src]

impl SaturatingCast<u128> for f64[src]

impl SaturatingCast<u128> for i8[src]

impl SaturatingCast<u128> for i16[src]

impl SaturatingCast<u128> for i32[src]

impl SaturatingCast<u128> for i64[src]

impl SaturatingCast<u128> for i128[src]

impl SaturatingCast<u128> for isize[src]

impl SaturatingCast<u128> for u8[src]

impl SaturatingCast<u128> for u16[src]

impl SaturatingCast<u128> for u32[src]

impl SaturatingCast<u128> for u64[src]

impl SaturatingCast<u128> for u128[src]

impl SaturatingCast<u128> for usize[src]

impl SaturatingCast<usize> for Round<f32>[src]

impl SaturatingCast<usize> for Round<f64>[src]

impl SaturatingCast<usize> for bool[src]

impl SaturatingCast<usize> for f32[src]

impl SaturatingCast<usize> for f64[src]

impl SaturatingCast<usize> for i8[src]

impl SaturatingCast<usize> for i16[src]

impl SaturatingCast<usize> for i32[src]

impl SaturatingCast<usize> for i64[src]

impl SaturatingCast<usize> for i128[src]

impl SaturatingCast<usize> for isize[src]

impl SaturatingCast<usize> for u8[src]

impl SaturatingCast<usize> for u16[src]

impl SaturatingCast<usize> for u32[src]

impl SaturatingCast<usize> for u64[src]

impl SaturatingCast<usize> for u128[src]

impl SaturatingCast<usize> for usize[src]

Loading content...