Function az::wrapping_cast[][src]

pub fn wrapping_cast<Src: WrappingCast<Dst>, Dst>(src: Src) -> Dst

Casts the value, wrapping on overflow.

Panics

Panics if the value does not fit and cannot be wrapped, for example when trying to cast floating-point ∞ into an integer type.

Examples

assert_eq!(az::wrapping_cast::<i32, u32>(-1), u32::max_value());
assert_eq!(az::wrapping_cast::<f32, u8>(17.0 + 256.0), 17);