Function az::checked_cast [−][src]
pub fn checked_cast<Src: CheckedCast<Dst>, Dst>(src: Src) -> Option<Dst>
Casts the value, returning None
if the value does not fit.
Examples
use core::f32; assert_eq!(az::checked_cast::<i32, u32>(5), Some(5)); assert_eq!(az::checked_cast::<i32, u32>(-5), None); assert_eq!(az::checked_cast::<f32, u8>(17.1), Some(17)); assert_eq!(az::checked_cast::<f32, u8>(f32::NAN), None);