pub trait IntoAs<T> {
// Required method
fn into_as(self) -> T;
}Expand description
The IntoAs trait for convert into value between integer types with possible overflow.
§Usage
Basic use of the trait.
use num_convert::IntoAs;
assert_eq!(IntoAs::<u8>::into_as(256_u16), 0_u8);
assert_eq!(<u8 as IntoAs<i8>>::into_as(156_u8), -100_i8);§Examples
let int: u8 = 612_u16.into_as();
assert_eq!(int, 100_u8);
assert_eq!(<u8 as IntoAs<i8>>::into_as(127_u8), 127_i8);