Trait az::OverflowingCast[][src]

pub trait OverflowingCast<Dst> {
    fn overflowing_cast(self) -> (Dst, bool);
}

Used for overflowing casts.

This trait’s method returns a tuple of the value and a bool, indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

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

Examples

use az::OverflowingCast;
let a: (u8, bool) = 17i32.overflowing_cast();
assert_eq!(a, (17, false));
assert_eq!(OverflowingCast::<u32>::overflowing_cast(-1), (u32::max_value(), true));
assert_eq!(OverflowingCast::<u8>::overflowing_cast(17.0 + 256.0), (17, true));

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.

Required methods

fn overflowing_cast(self) -> (Dst, bool)[src]

Casts the value.

Loading content...

Implementors

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

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

impl OverflowingCast<i8> for bool[src]

impl OverflowingCast<i8> for f32[src]

impl OverflowingCast<i8> for f64[src]

impl OverflowingCast<i8> for i8[src]

impl OverflowingCast<i8> for i16[src]

impl OverflowingCast<i8> for i32[src]

impl OverflowingCast<i8> for i64[src]

impl OverflowingCast<i8> for i128[src]

impl OverflowingCast<i8> for isize[src]

impl OverflowingCast<i8> for u8[src]

impl OverflowingCast<i8> for u16[src]

impl OverflowingCast<i8> for u32[src]

impl OverflowingCast<i8> for u64[src]

impl OverflowingCast<i8> for u128[src]

impl OverflowingCast<i8> for usize[src]

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

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

impl OverflowingCast<i16> for bool[src]

impl OverflowingCast<i16> for f32[src]

impl OverflowingCast<i16> for f64[src]

impl OverflowingCast<i16> for i8[src]

impl OverflowingCast<i16> for i16[src]

impl OverflowingCast<i16> for i32[src]

impl OverflowingCast<i16> for i64[src]

impl OverflowingCast<i16> for i128[src]

impl OverflowingCast<i16> for isize[src]

impl OverflowingCast<i16> for u8[src]

impl OverflowingCast<i16> for u16[src]

impl OverflowingCast<i16> for u32[src]

impl OverflowingCast<i16> for u64[src]

impl OverflowingCast<i16> for u128[src]

impl OverflowingCast<i16> for usize[src]

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

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

impl OverflowingCast<i32> for bool[src]

impl OverflowingCast<i32> for f32[src]

impl OverflowingCast<i32> for f64[src]

impl OverflowingCast<i32> for i8[src]

impl OverflowingCast<i32> for i16[src]

impl OverflowingCast<i32> for i32[src]

impl OverflowingCast<i32> for i64[src]

impl OverflowingCast<i32> for i128[src]

impl OverflowingCast<i32> for isize[src]

impl OverflowingCast<i32> for u8[src]

impl OverflowingCast<i32> for u16[src]

impl OverflowingCast<i32> for u32[src]

impl OverflowingCast<i32> for u64[src]

impl OverflowingCast<i32> for u128[src]

impl OverflowingCast<i32> for usize[src]

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

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

impl OverflowingCast<i64> for bool[src]

impl OverflowingCast<i64> for f32[src]

impl OverflowingCast<i64> for f64[src]

impl OverflowingCast<i64> for i8[src]

impl OverflowingCast<i64> for i16[src]

impl OverflowingCast<i64> for i32[src]

impl OverflowingCast<i64> for i64[src]

impl OverflowingCast<i64> for i128[src]

impl OverflowingCast<i64> for isize[src]

impl OverflowingCast<i64> for u8[src]

impl OverflowingCast<i64> for u16[src]

impl OverflowingCast<i64> for u32[src]

impl OverflowingCast<i64> for u64[src]

impl OverflowingCast<i64> for u128[src]

impl OverflowingCast<i64> for usize[src]

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

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

impl OverflowingCast<i128> for bool[src]

impl OverflowingCast<i128> for f32[src]

impl OverflowingCast<i128> for f64[src]

impl OverflowingCast<i128> for i8[src]

impl OverflowingCast<i128> for i16[src]

impl OverflowingCast<i128> for i32[src]

impl OverflowingCast<i128> for i64[src]

impl OverflowingCast<i128> for i128[src]

impl OverflowingCast<i128> for isize[src]

impl OverflowingCast<i128> for u8[src]

impl OverflowingCast<i128> for u16[src]

impl OverflowingCast<i128> for u32[src]

impl OverflowingCast<i128> for u64[src]

impl OverflowingCast<i128> for u128[src]

impl OverflowingCast<i128> for usize[src]

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

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

impl OverflowingCast<isize> for bool[src]

impl OverflowingCast<isize> for f32[src]

impl OverflowingCast<isize> for f64[src]

impl OverflowingCast<isize> for i8[src]

impl OverflowingCast<isize> for i16[src]

impl OverflowingCast<isize> for i32[src]

impl OverflowingCast<isize> for i64[src]

impl OverflowingCast<isize> for i128[src]

impl OverflowingCast<isize> for isize[src]

impl OverflowingCast<isize> for u8[src]

impl OverflowingCast<isize> for u16[src]

impl OverflowingCast<isize> for u32[src]

impl OverflowingCast<isize> for u64[src]

impl OverflowingCast<isize> for u128[src]

impl OverflowingCast<isize> for usize[src]

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

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

impl OverflowingCast<u8> for bool[src]

impl OverflowingCast<u8> for f32[src]

impl OverflowingCast<u8> for f64[src]

impl OverflowingCast<u8> for i8[src]

impl OverflowingCast<u8> for i16[src]

impl OverflowingCast<u8> for i32[src]

impl OverflowingCast<u8> for i64[src]

impl OverflowingCast<u8> for i128[src]

impl OverflowingCast<u8> for isize[src]

impl OverflowingCast<u8> for u8[src]

impl OverflowingCast<u8> for u16[src]

impl OverflowingCast<u8> for u32[src]

impl OverflowingCast<u8> for u64[src]

impl OverflowingCast<u8> for u128[src]

impl OverflowingCast<u8> for usize[src]

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

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

impl OverflowingCast<u16> for bool[src]

impl OverflowingCast<u16> for f32[src]

impl OverflowingCast<u16> for f64[src]

impl OverflowingCast<u16> for i8[src]

impl OverflowingCast<u16> for i16[src]

impl OverflowingCast<u16> for i32[src]

impl OverflowingCast<u16> for i64[src]

impl OverflowingCast<u16> for i128[src]

impl OverflowingCast<u16> for isize[src]

impl OverflowingCast<u16> for u8[src]

impl OverflowingCast<u16> for u16[src]

impl OverflowingCast<u16> for u32[src]

impl OverflowingCast<u16> for u64[src]

impl OverflowingCast<u16> for u128[src]

impl OverflowingCast<u16> for usize[src]

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

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

impl OverflowingCast<u32> for bool[src]

impl OverflowingCast<u32> for f32[src]

impl OverflowingCast<u32> for f64[src]

impl OverflowingCast<u32> for i8[src]

impl OverflowingCast<u32> for i16[src]

impl OverflowingCast<u32> for i32[src]

impl OverflowingCast<u32> for i64[src]

impl OverflowingCast<u32> for i128[src]

impl OverflowingCast<u32> for isize[src]

impl OverflowingCast<u32> for u8[src]

impl OverflowingCast<u32> for u16[src]

impl OverflowingCast<u32> for u32[src]

impl OverflowingCast<u32> for u64[src]

impl OverflowingCast<u32> for u128[src]

impl OverflowingCast<u32> for usize[src]

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

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

impl OverflowingCast<u64> for bool[src]

impl OverflowingCast<u64> for f32[src]

impl OverflowingCast<u64> for f64[src]

impl OverflowingCast<u64> for i8[src]

impl OverflowingCast<u64> for i16[src]

impl OverflowingCast<u64> for i32[src]

impl OverflowingCast<u64> for i64[src]

impl OverflowingCast<u64> for i128[src]

impl OverflowingCast<u64> for isize[src]

impl OverflowingCast<u64> for u8[src]

impl OverflowingCast<u64> for u16[src]

impl OverflowingCast<u64> for u32[src]

impl OverflowingCast<u64> for u64[src]

impl OverflowingCast<u64> for u128[src]

impl OverflowingCast<u64> for usize[src]

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

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

impl OverflowingCast<u128> for bool[src]

impl OverflowingCast<u128> for f32[src]

impl OverflowingCast<u128> for f64[src]

impl OverflowingCast<u128> for i8[src]

impl OverflowingCast<u128> for i16[src]

impl OverflowingCast<u128> for i32[src]

impl OverflowingCast<u128> for i64[src]

impl OverflowingCast<u128> for i128[src]

impl OverflowingCast<u128> for isize[src]

impl OverflowingCast<u128> for u8[src]

impl OverflowingCast<u128> for u16[src]

impl OverflowingCast<u128> for u32[src]

impl OverflowingCast<u128> for u64[src]

impl OverflowingCast<u128> for u128[src]

impl OverflowingCast<u128> for usize[src]

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

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

impl OverflowingCast<usize> for bool[src]

impl OverflowingCast<usize> for f32[src]

impl OverflowingCast<usize> for f64[src]

impl OverflowingCast<usize> for i8[src]

impl OverflowingCast<usize> for i16[src]

impl OverflowingCast<usize> for i32[src]

impl OverflowingCast<usize> for i64[src]

impl OverflowingCast<usize> for i128[src]

impl OverflowingCast<usize> for isize[src]

impl OverflowingCast<usize> for u8[src]

impl OverflowingCast<usize> for u16[src]

impl OverflowingCast<usize> for u32[src]

impl OverflowingCast<usize> for u64[src]

impl OverflowingCast<usize> for u128[src]

impl OverflowingCast<usize> for usize[src]

Loading content...