Function az::unwrapped_cast[][src]

pub fn unwrapped_cast<Src: UnwrappedCast<Dst>, Dst>(src: Src) -> Dst

Casts the value, panicking if the value does not fit.

Panics

Panics if the value does not fit in the destination, even when debug assertions are not enabled.

Examples

assert_eq!(az::unwrapped_cast::<i32, u32>(5), 5);
assert_eq!(az::unwrapped_cast::<f32, u8>(17.1), 17);

The following panics because of overflow.

let _overflow = az::unwrapped_cast::<i32, u32>(-5);