num_conv

Trait Extend

Source
pub trait Extend: Integer {
    // Required method
    fn extend<T>(self) -> T
       where Self: ExtendTarget<T>;
}
Expand description

Extend to an integer of the same size or larger, preserving its value.

assert_eq!(0_u8.extend::<u16>(), 0_u16);
assert_eq!(0_u16.extend::<u32>(), 0_u32);
assert_eq!(0_u32.extend::<u64>(), 0_u64);
assert_eq!(0_u64.extend::<u128>(), 0_u128);
assert_eq!((-1_i8).extend::<i16>(), -1_i16);
assert_eq!((-1_i16).extend::<i32>(), -1_i32);
assert_eq!((-1_i32).extend::<i64>(), -1_i64);
assert_eq!((-1_i64).extend::<i128>(), -1_i128);

Required Methods§

Source

fn extend<T>(self) -> T
where Self: ExtendTarget<T>,

Extend an integer to an integer of the same size or larger, preserving its value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Integer> Extend for T