Trait num_convert::IntoByAdd
source · pub trait IntoByAdd<T> {
// Required method
fn into_by_add(self) -> T;
}Expand description
A generic trait for converting into possible types.
Examples
Usage:
fn convert_into_u8<T: IntoByAdd<u8>>(min: T, max: T) -> (u8, u8) {
(min.into_by_add(), max.into_by_add())
}
assert_eq!(convert_into_u8(i8::MIN, i8::MAX), (u8::MIN, u8::MAX));
assert_eq!(<i16 as IntoByAdd<u16>>::into_by_add( i16::MIN), u16::MIN);
assert_eq!(<i32 as IntoByAdd<u128>>::into_by_add( i32::MIN), u32::MIN as u128);
assert_eq!(IntoByAdd::<u64>::into_by_add(i8::MAX), u8::MAX as u64);
//```Required Methods§
sourcefn into_by_add(self) -> T
fn into_by_add(self) -> T
Converts the value of self to an T.