[][src]Trait az::Cast

pub trait Cast<Dst> {
    fn cast(self) -> Dst;

Used to cast values.

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


When debug assertions are enabled, this trait’s method panics if the value does not fit in the destination. When debug assertions are not enabled (usual in release mode), the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use WrappingCast instead.

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


use az::Cast;
let a: u32 = 5i32.cast();
assert_eq!(a, 5);
assert_eq!(Cast::<u8>::cast(17.1f32), 17);

Required methods

fn cast(self) -> Dst

Casts the value.

Loading content...


impl Cast<Wrapping<i8>> for bool[src]

impl Cast<Wrapping<i8>> for isize[src]

impl Cast<Wrapping<i8>> for usize[src]

impl Cast<Wrapping<i16>> for bool[src]

impl Cast<Wrapping<i16>> for isize[src]

impl Cast<Wrapping<i16>> for usize[src]

impl Cast<Wrapping<i32>> for bool[src]

impl Cast<Wrapping<i32>> for isize[src]

impl Cast<Wrapping<i32>> for usize[src]

impl Cast<Wrapping<i64>> for bool[src]

impl Cast<Wrapping<i64>> for isize[src]

impl Cast<Wrapping<i64>> for usize[src]

impl Cast<Wrapping<i128>> for bool[src]

impl Cast<Wrapping<i128>> for isize[src]

impl Cast<Wrapping<i128>> for usize[src]

impl Cast<Wrapping<i128>> for Round<f32>[src]

impl Cast<Wrapping<i128>> for Round<f64>[src]

impl Cast<Wrapping<i128>> for f32[src]

impl Cast<Wrapping<i128>> for f64[src]

impl Cast<Wrapping<i128>> for i8[src]

impl Cast<Wrapping<i128>> for i16[src]

impl Cast<Wrapping<i128>> for i32[src]

impl Cast<Wrapping<i128>> for i64[src]

impl Cast<Wrapping<i128>> for i128[src]

impl Cast<Wrapping<i128>> for u8[src]

impl Cast<Wrapping<i128>> for u16[src]

impl Cast<Wrapping<i128>> for u32[src]

impl Cast<Wrapping<i128>> for u64[src]

impl Cast<Wrapping<i128>> for u128[src]

impl Cast<Wrapping<i16>> for Round<f32>[src]

impl Cast<Wrapping<i16>> for Round<f64>[src]

impl Cast<Wrapping<i16>> for f32[src]

impl Cast<Wrapping<i16>> for f64[src]

impl Cast<Wrapping<i16>> for i8[src]

impl Cast<Wrapping<i16>> for i16[src]

impl Cast<Wrapping<i16>> for i32[src]

impl Cast<Wrapping<i16>> for i64[src]

impl Cast<Wrapping<i16>> for i128[src]

impl Cast<Wrapping<i16>> for u8[src]

impl Cast<Wrapping<i16>> for u16[src]

impl Cast<Wrapping<i16>> for u32[src]

impl Cast<Wrapping<i16>> for u64[src]

impl Cast<Wrapping<i16>> for u128[src]

impl Cast<Wrapping<i32>> for Round<f32>[src]

impl Cast<Wrapping<i32>> for Round<f64>[src]

impl Cast<Wrapping<i32>> for f32[src]

impl Cast<Wrapping<i32>> for f64[src]

impl Cast<Wrapping<i32>> for i8[src]

impl Cast<Wrapping<i32>> for i16[src]

impl Cast<Wrapping<i32>> for i32[src]

impl Cast<Wrapping<i32>> for i64[src]

impl Cast<Wrapping<i32>> for i128[src]

impl Cast<Wrapping<i32>> for u8[src]

impl Cast<Wrapping<i32>> for u16[src]

impl Cast<Wrapping<i32>> for u32[src]

impl Cast<Wrapping<i32>> for u64[src]

impl Cast<Wrapping<i32>> for u128[src]

impl Cast<Wrapping<i64>> for Round<f32>[src]

impl Cast<Wrapping<i64>> for Round<f64>[src]

impl Cast<Wrapping<i64>> for f32[src]

impl Cast<Wrapping<i64>> for f64[src]

impl Cast<Wrapping<i64>> for i8[src]

impl Cast<Wrapping<i64>> for i16[src]

impl Cast<Wrapping<i64>> for i32[src]

impl Cast<Wrapping<i64>> for i64[src]

impl Cast<Wrapping<i64>> for i128[src]

impl Cast<Wrapping<i64>> for u8[src]

impl Cast<Wrapping<i64>> for u16[src]

impl Cast<Wrapping<i64>> for u32[src]

impl Cast<Wrapping<i64>> for u64[src]

impl Cast<Wrapping<i64>> for u128[src]

impl Cast<Wrapping<i8>> for Round<f32>[src]

impl Cast<Wrapping<i8>> for Round<f64>[src]

impl Cast<Wrapping<i8>> for f32[src]

impl Cast<Wrapping<i8>> for f64[src]

impl Cast<Wrapping<i8>> for i8[src]

impl Cast<Wrapping<i8>> for i16[src]

impl Cast<Wrapping<i8>> for i32[src]

impl Cast<Wrapping<i8>> for i64[src]

impl Cast<Wrapping<i8>> for i128[src]

impl Cast<Wrapping<i8>> for u8[src]

impl Cast<Wrapping<i8>> for u16[src]

impl Cast<Wrapping<i8>> for u32[src]

impl Cast<Wrapping<i8>> for u64[src]

impl Cast<Wrapping<i8>> for u128[src]

impl Cast<Wrapping<isize>> for Round<f32>[src]

impl Cast<Wrapping<isize>> for Round<f64>[src]

impl Cast<Wrapping<isize>> for bool[src]

impl Cast<Wrapping<isize>> for f32[src]

impl Cast<Wrapping<isize>> for f64[src]

impl Cast<Wrapping<isize>> for i8[src]

impl Cast<Wrapping<isize>> for i16[src]

impl Cast<Wrapping<isize>> for i32[src]

impl Cast<Wrapping<isize>> for i64[src]

impl Cast<Wrapping<isize>> for i128[src]

impl Cast<Wrapping<isize>> for isize[src]

impl Cast<Wrapping<isize>> for u8[src]

impl Cast<Wrapping<isize>> for u16[src]

impl Cast<Wrapping<isize>> for u32[src]

impl Cast<Wrapping<isize>> for u64[src]

impl Cast<Wrapping<isize>> for u128[src]

impl Cast<Wrapping<isize>> for usize[src]

impl Cast<Wrapping<u8>> for bool[src]

impl Cast<Wrapping<u8>> for isize[src]

impl Cast<Wrapping<u8>> for usize[src]

impl Cast<Wrapping<u16>> for bool[src]

impl Cast<Wrapping<u16>> for isize[src]

impl Cast<Wrapping<u16>> for usize[src]

impl Cast<Wrapping<u32>> for bool[src]

impl Cast<Wrapping<u32>> for isize[src]

impl Cast<Wrapping<u32>> for usize[src]

impl Cast<Wrapping<u64>> for bool[src]

impl Cast<Wrapping<u64>> for isize[src]

impl Cast<Wrapping<u64>> for usize[src]

impl Cast<Wrapping<u128>> for bool[src]

impl Cast<Wrapping<u128>> for isize[src]

impl Cast<Wrapping<u128>> for usize[src]

impl Cast<Wrapping<u128>> for Round<f32>[src]

impl Cast<Wrapping<u128>> for Round<f64>[src]

impl Cast<Wrapping<u128>> for f32[src]

impl Cast<Wrapping<u128>> for f64[src]

impl Cast<Wrapping<u128>> for i8[src]

impl Cast<Wrapping<u128>> for i16[src]

impl Cast<Wrapping<u128>> for i32[src]

impl Cast<Wrapping<u128>> for i64[src]

impl Cast<Wrapping<u128>> for i128[src]

impl Cast<Wrapping<u128>> for u8[src]

impl Cast<Wrapping<u128>> for u16[src]

impl Cast<Wrapping<u128>> for u32[src]

impl Cast<Wrapping<u128>> for u64[src]

impl Cast<Wrapping<u128>> for u128[src]

impl Cast<Wrapping<u16>> for Round<f32>[src]

impl Cast<Wrapping<u16>> for Round<f64>[src]

impl Cast<Wrapping<u16>> for f32[src]

impl Cast<Wrapping<u16>> for f64[src]

impl Cast<Wrapping<u16>> for i8[src]

impl Cast<Wrapping<u16>> for i16[src]

impl Cast<Wrapping<u16>> for i32[src]

impl Cast<Wrapping<u16>> for i64[src]

impl Cast<Wrapping<u16>> for i128[src]

impl Cast<Wrapping<u16>> for u8[src]

impl Cast<Wrapping<u16>> for u16[src]

impl Cast<Wrapping<u16>> for u32[src]

impl Cast<Wrapping<u16>> for u64[src]

impl Cast<Wrapping<u16>> for u128[src]

impl Cast<Wrapping<u32>> for Round<f32>[src]

impl Cast<Wrapping<u32>> for Round<f64>[src]

impl Cast<Wrapping<u32>> for f32[src]

impl Cast<Wrapping<u32>> for f64[src]

impl Cast<Wrapping<u32>> for i8[src]

impl Cast<Wrapping<u32>> for i16[src]

impl Cast<Wrapping<u32>> for i32[src]

impl Cast<Wrapping<u32>> for i64[src]

impl Cast<Wrapping<u32>> for i128[src]

impl Cast<Wrapping<u32>> for u8[src]

impl Cast<Wrapping<u32>> for u16[src]

impl Cast<Wrapping<u32>> for u32[src]

impl Cast<Wrapping<u32>> for u64[src]

impl Cast<Wrapping<u32>> for u128[src]

impl Cast<Wrapping<u64>> for Round<f32>[src]

impl Cast<Wrapping<u64>> for Round<f64>[src]

impl Cast<Wrapping<u64>> for f32[src]

impl Cast<Wrapping<u64>> for f64[src]

impl Cast<Wrapping<u64>> for i8[src]

impl Cast<Wrapping<u64>> for i16[src]

impl Cast<Wrapping<u64>> for i32[src]

impl Cast<Wrapping<u64>> for i64[src]

impl Cast<Wrapping<u64>> for i128[src]

impl Cast<Wrapping<u64>> for u8[src]

impl Cast<Wrapping<u64>> for u16[src]

impl Cast<Wrapping<u64>> for u32[src]

impl Cast<Wrapping<u64>> for u64[src]

impl Cast<Wrapping<u64>> for u128[src]

impl Cast<Wrapping<u8>> for Round<f32>[src]

impl Cast<Wrapping<u8>> for Round<f64>[src]

impl Cast<Wrapping<u8>> for f32[src]

impl Cast<Wrapping<u8>> for f64[src]

impl Cast<Wrapping<u8>> for i8[src]

impl Cast<Wrapping<u8>> for i16[src]

impl Cast<Wrapping<u8>> for i32[src]

impl Cast<Wrapping<u8>> for i64[src]

impl Cast<Wrapping<u8>> for i128[src]

impl Cast<Wrapping<u8>> for u8[src]

impl Cast<Wrapping<u8>> for u16[src]

impl Cast<Wrapping<u8>> for u32[src]

impl Cast<Wrapping<u8>> for u64[src]

impl Cast<Wrapping<u8>> for u128[src]

impl Cast<Wrapping<usize>> for Round<f32>[src]

impl Cast<Wrapping<usize>> for Round<f64>[src]

impl Cast<Wrapping<usize>> for bool[src]

impl Cast<Wrapping<usize>> for f32[src]

impl Cast<Wrapping<usize>> for f64[src]

impl Cast<Wrapping<usize>> for i8[src]

impl Cast<Wrapping<usize>> for i16[src]

impl Cast<Wrapping<usize>> for i32[src]

impl Cast<Wrapping<usize>> for i64[src]

impl Cast<Wrapping<usize>> for i128[src]

impl Cast<Wrapping<usize>> for isize[src]

impl Cast<Wrapping<usize>> for u8[src]

impl Cast<Wrapping<usize>> for u16[src]

impl Cast<Wrapping<usize>> for u32[src]

impl Cast<Wrapping<usize>> for u64[src]

impl Cast<Wrapping<usize>> for u128[src]

impl Cast<Wrapping<usize>> for usize[src]

impl Cast<f32> for isize[src]

impl Cast<f32> for usize[src]

impl Cast<f64> for isize[src]

impl Cast<f64> for usize[src]

impl Cast<f32> for f32[src]

impl Cast<f32> for f64[src]

impl Cast<f32> for i8[src]

impl Cast<f32> for i16[src]

impl Cast<f32> for i32[src]

impl Cast<f32> for i64[src]

impl Cast<f32> for i128[src]

impl Cast<f32> for u8[src]

impl Cast<f32> for u16[src]

impl Cast<f32> for u32[src]

impl Cast<f32> for u64[src]

impl Cast<f32> for u128[src]

impl Cast<f64> for f32[src]

impl Cast<f64> for f64[src]

impl Cast<f64> for i8[src]

impl Cast<f64> for i16[src]

impl Cast<f64> for i32[src]

impl Cast<f64> for i64[src]

impl Cast<f64> for i128[src]

impl Cast<f64> for u8[src]

impl Cast<f64> for u16[src]

impl Cast<f64> for u32[src]

impl Cast<f64> for u64[src]

impl Cast<f64> for u128[src]

impl Cast<i8> for bool[src]

impl Cast<i8> for isize[src]

impl Cast<i8> for usize[src]

impl Cast<i16> for bool[src]

impl Cast<i16> for isize[src]

impl Cast<i16> for usize[src]

impl Cast<i32> for bool[src]

impl Cast<i32> for isize[src]

impl Cast<i32> for usize[src]

impl Cast<i64> for bool[src]

impl Cast<i64> for isize[src]

impl Cast<i64> for usize[src]

impl Cast<i128> for bool[src]

impl Cast<i128> for isize[src]

impl Cast<i128> for usize[src]

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

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

impl Cast<i128> for f32[src]

impl Cast<i128> for f64[src]

impl Cast<i128> for i8[src]

impl Cast<i128> for i16[src]

impl Cast<i128> for i32[src]

impl Cast<i128> for i64[src]

impl Cast<i128> for i128[src]

impl Cast<i128> for u8[src]

impl Cast<i128> for u16[src]

impl Cast<i128> for u32[src]

impl Cast<i128> for u64[src]

impl Cast<i128> for u128[src]

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

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

impl Cast<i16> for f32[src]

impl Cast<i16> for f64[src]

impl Cast<i16> for i8[src]

impl Cast<i16> for i16[src]

impl Cast<i16> for i32[src]

impl Cast<i16> for i64[src]

impl Cast<i16> for i128[src]

impl Cast<i16> for u8[src]

impl Cast<i16> for u16[src]

impl Cast<i16> for u32[src]

impl Cast<i16> for u64[src]

impl Cast<i16> for u128[src]

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

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

impl Cast<i32> for f32[src]

impl Cast<i32> for f64[src]

impl Cast<i32> for i8[src]

impl Cast<i32> for i16[src]

impl Cast<i32> for i32[src]

impl Cast<i32> for i64[src]

impl Cast<i32> for i128[src]

impl Cast<i32> for u8[src]

impl Cast<i32> for u16[src]

impl Cast<i32> for u32[src]

impl Cast<i32> for u64[src]

impl Cast<i32> for u128[src]

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

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

impl Cast<i64> for f32[src]

impl Cast<i64> for f64[src]

impl Cast<i64> for i8[src]

impl Cast<i64> for i16[src]

impl Cast<i64> for i32[src]

impl Cast<i64> for i64[src]

impl Cast<i64> for i128[src]

impl Cast<i64> for u8[src]

impl Cast<i64> for u16[src]

impl Cast<i64> for u32[src]

impl Cast<i64> for u64[src]

impl Cast<i64> for u128[src]

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

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

impl Cast<i8> for f32[src]

impl Cast<i8> for f64[src]

impl Cast<i8> for i8[src]

impl Cast<i8> for i16[src]

impl Cast<i8> for i32[src]

impl Cast<i8> for i64[src]

impl Cast<i8> for i128[src]

impl Cast<i8> for u8[src]

impl Cast<i8> for u16[src]

impl Cast<i8> for u32[src]

impl Cast<i8> for u64[src]

impl Cast<i8> for u128[src]

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

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

impl Cast<isize> for bool[src]

impl Cast<isize> for f32[src]

impl Cast<isize> for f64[src]

impl Cast<isize> for i8[src]

impl Cast<isize> for i16[src]

impl Cast<isize> for i32[src]

impl Cast<isize> for i64[src]

impl Cast<isize> for i128[src]

impl Cast<isize> for isize[src]

impl Cast<isize> for u8[src]

impl Cast<isize> for u16[src]

impl Cast<isize> for u32[src]

impl Cast<isize> for u64[src]

impl Cast<isize> for u128[src]

impl Cast<isize> for usize[src]

impl Cast<u8> for bool[src]

impl Cast<u8> for isize[src]

impl Cast<u8> for usize[src]

impl Cast<u16> for bool[src]

impl Cast<u16> for isize[src]

impl Cast<u16> for usize[src]

impl Cast<u32> for bool[src]

impl Cast<u32> for isize[src]

impl Cast<u32> for usize[src]

impl Cast<u64> for bool[src]

impl Cast<u64> for isize[src]

impl Cast<u64> for usize[src]

impl Cast<u128> for bool[src]

impl Cast<u128> for isize[src]

impl Cast<u128> for usize[src]

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

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

impl Cast<u128> for f32[src]

impl Cast<u128> for f64[src]

impl Cast<u128> for i8[src]

impl Cast<u128> for i16[src]

impl Cast<u128> for i32[src]

impl Cast<u128> for i64[src]

impl Cast<u128> for i128[src]

impl Cast<u128> for u8[src]

impl Cast<u128> for u16[src]

impl Cast<u128> for u32[src]

impl Cast<u128> for u64[src]

impl Cast<u128> for u128[src]

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

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

impl Cast<u16> for f32[src]

impl Cast<u16> for f64[src]

impl Cast<u16> for i8[src]

impl Cast<u16> for i16[src]

impl Cast<u16> for i32[src]

impl Cast<u16> for i64[src]

impl Cast<u16> for i128[src]

impl Cast<u16> for u8[src]

impl Cast<u16> for u16[src]

impl Cast<u16> for u32[src]

impl Cast<u16> for u64[src]

impl Cast<u16> for u128[src]

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

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

impl Cast<u32> for f32[src]

impl Cast<u32> for f64[src]

impl Cast<u32> for i8[src]

impl Cast<u32> for i16[src]

impl Cast<u32> for i32[src]

impl Cast<u32> for i64[src]

impl Cast<u32> for i128[src]

impl Cast<u32> for u8[src]

impl Cast<u32> for u16[src]

impl Cast<u32> for u32[src]

impl Cast<u32> for u64[src]

impl Cast<u32> for u128[src]

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

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

impl Cast<u64> for f32[src]

impl Cast<u64> for f64[src]

impl Cast<u64> for i8[src]

impl Cast<u64> for i16[src]

impl Cast<u64> for i32[src]

impl Cast<u64> for i64[src]

impl Cast<u64> for i128[src]

impl Cast<u64> for u8[src]

impl Cast<u64> for u16[src]

impl Cast<u64> for u32[src]

impl Cast<u64> for u64[src]

impl Cast<u64> for u128[src]

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

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

impl Cast<u8> for f32[src]

impl Cast<u8> for f64[src]

impl Cast<u8> for i8[src]

impl Cast<u8> for i16[src]

impl Cast<u8> for i32[src]

impl Cast<u8> for i64[src]

impl Cast<u8> for i128[src]

impl Cast<u8> for u8[src]

impl Cast<u8> for u16[src]

impl Cast<u8> for u32[src]

impl Cast<u8> for u64[src]

impl Cast<u8> for u128[src]

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

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

impl Cast<usize> for bool[src]

impl Cast<usize> for f32[src]

impl Cast<usize> for f64[src]

impl Cast<usize> for i8[src]

impl Cast<usize> for i16[src]

impl Cast<usize> for i32[src]

impl Cast<usize> for i64[src]

impl Cast<usize> for i128[src]

impl Cast<usize> for isize[src]

impl Cast<usize> for u8[src]

impl Cast<usize> for u16[src]

impl Cast<usize> for u32[src]

impl Cast<usize> for u64[src]

impl Cast<usize> for u128[src]

impl Cast<usize> for usize[src]

Loading content...