Trait az::SaturatingCast

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

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§

source

fn saturating_cast(self) -> Dst

Casts the value.

Implementations on Foreign Types§

source§

impl SaturatingCast<i8> for bool

source§

impl SaturatingCast<i8> for f32

source§

impl SaturatingCast<i8> for f64

source§

impl SaturatingCast<i8> for i8

source§

impl SaturatingCast<i8> for i16

source§

impl SaturatingCast<i8> for i32

source§

impl SaturatingCast<i8> for i64

source§

impl SaturatingCast<i8> for i128

source§

impl SaturatingCast<i8> for isize

source§

impl SaturatingCast<i8> for u8

source§

impl SaturatingCast<i8> for u16

source§

impl SaturatingCast<i8> for u32

source§

impl SaturatingCast<i8> for u64

source§

impl SaturatingCast<i8> for u128

source§

impl SaturatingCast<i8> for usize

source§

impl SaturatingCast<i16> for bool

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for f32

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for f64

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for i8

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for i16

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for i32

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for i64

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for i128

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for isize

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for u8

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for u16

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for u32

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for u64

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for u128

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i16> for usize

source§

fn saturating_cast(self) -> i16

source§

impl SaturatingCast<i32> for bool

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for f32

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for f64

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for i8

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for i16

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for i32

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for i64

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for i128

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for isize

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for u8

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for u16

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for u32

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for u64

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for u128

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i32> for usize

source§

fn saturating_cast(self) -> i32

source§

impl SaturatingCast<i64> for bool

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for f32

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for f64

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for i8

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for i16

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for i32

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for i64

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for i128

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for isize

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for u8

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for u16

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for u32

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for u64

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for u128

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i64> for usize

source§

fn saturating_cast(self) -> i64

source§

impl SaturatingCast<i128> for bool

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for f32

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for f64

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for i8

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for i16

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for i32

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for i64

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for i128

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for isize

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for u8

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for u16

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for u32

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for u64

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for u128

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<i128> for usize

source§

fn saturating_cast(self) -> i128

source§

impl SaturatingCast<isize> for bool

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for f32

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for f64

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for i8

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for i16

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for i32

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for i64

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for i128

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for isize

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for u8

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for u16

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for u32

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for u64

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for u128

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<isize> for usize

source§

fn saturating_cast(self) -> isize

source§

impl SaturatingCast<u8> for bool

source§

impl SaturatingCast<u8> for f32

source§

impl SaturatingCast<u8> for f64

source§

impl SaturatingCast<u8> for i8

source§

impl SaturatingCast<u8> for i16

source§

impl SaturatingCast<u8> for i32

source§

impl SaturatingCast<u8> for i64

source§

impl SaturatingCast<u8> for i128

source§

impl SaturatingCast<u8> for isize

source§

impl SaturatingCast<u8> for u8

source§

impl SaturatingCast<u8> for u16

source§

impl SaturatingCast<u8> for u32

source§

impl SaturatingCast<u8> for u64

source§

impl SaturatingCast<u8> for u128

source§

impl SaturatingCast<u8> for usize

source§

impl SaturatingCast<u16> for bool

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for f32

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for f64

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for i8

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for i16

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for i32

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for i64

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for i128

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for isize

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for u8

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for u16

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for u32

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for u64

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for u128

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u16> for usize

source§

fn saturating_cast(self) -> u16

source§

impl SaturatingCast<u32> for bool

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for f32

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for f64

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for i8

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for i16

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for i32

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for i64

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for i128

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for isize

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for u8

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for u16

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for u32

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for u64

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for u128

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u32> for usize

source§

fn saturating_cast(self) -> u32

source§

impl SaturatingCast<u64> for bool

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for f32

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for f64

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for i8

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for i16

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for i32

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for i64

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for i128

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for isize

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for u8

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for u16

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for u32

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for u64

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for u128

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u64> for usize

source§

fn saturating_cast(self) -> u64

source§

impl SaturatingCast<u128> for bool

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for f32

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for f64

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for i8

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for i16

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for i32

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for i64

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for i128

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for isize

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for u8

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for u16

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for u32

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for u64

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for u128

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<u128> for usize

source§

fn saturating_cast(self) -> u128

source§

impl SaturatingCast<usize> for bool

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for f32

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for f64

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for i8

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for i16

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for i32

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for i64

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for i128

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for isize

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for u8

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for u16

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for u32

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for u64

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for u128

source§

fn saturating_cast(self) -> usize

source§

impl SaturatingCast<usize> for usize

source§

fn saturating_cast(self) -> usize

Implementors§

source§

impl SaturatingCast<i8> for Round<f32>

source§

impl SaturatingCast<i8> for Round<f64>

source§

impl SaturatingCast<i16> for Round<f32>

source§

impl SaturatingCast<i16> for Round<f64>

source§

impl SaturatingCast<i32> for Round<f32>

source§

impl SaturatingCast<i32> for Round<f64>

source§

impl SaturatingCast<i64> for Round<f32>

source§

impl SaturatingCast<i64> for Round<f64>

source§

impl SaturatingCast<i128> for Round<f32>

source§

impl SaturatingCast<i128> for Round<f64>

source§

impl SaturatingCast<isize> for Round<f32>

source§

impl SaturatingCast<isize> for Round<f64>

source§

impl SaturatingCast<u8> for Round<f32>

source§

impl SaturatingCast<u8> for Round<f64>

source§

impl SaturatingCast<u16> for Round<f32>

source§

impl SaturatingCast<u16> for Round<f64>

source§

impl SaturatingCast<u32> for Round<f32>

source§

impl SaturatingCast<u32> for Round<f64>

source§

impl SaturatingCast<u64> for Round<f32>

source§

impl SaturatingCast<u64> for Round<f64>

source§

impl SaturatingCast<u128> for Round<f32>

source§

impl SaturatingCast<u128> for Round<f64>

source§

impl SaturatingCast<usize> for Round<f32>

source§

impl SaturatingCast<usize> for Round<f64>