Trait num_convert::CastIntoAs
source · pub trait CastIntoAs {
// Required methods
fn into_i8(self) -> i8;
fn into_i16(self) -> i16;
fn into_i32(self) -> i32;
fn into_i64(self) -> i64;
fn into_isize(self) -> isize;
fn into_i128(self) -> i128;
fn into_u8(self) -> u8;
fn into_u16(self) -> u16;
fn into_u32(self) -> u32;
fn into_u64(self) -> u64;
fn into_usize(self) -> usize;
fn into_u128(self) -> u128;
}Available on crate feature
cast_into_as only.Expand description
The CastIntoAs trait for simple convert self value between integer types with possible overflow.
Examples
Usage:
assert_eq!(255u16.into_u8(), 255u8);
assert_eq!(258u16.into_u8(), 2u8);Required Methods§
sourcefn into_i16(self) -> i16
fn into_i16(self) -> i16
Converts the value of self to i16. Overflow possible during conversion.
sourcefn into_i32(self) -> i32
fn into_i32(self) -> i32
Converts the value of self to i32. Overflow possible during conversion.
sourcefn into_i64(self) -> i64
fn into_i64(self) -> i64
Converts the value of self to i64. Overflow possible during conversion.
sourcefn into_isize(self) -> isize
fn into_isize(self) -> isize
Converts the value of self to isize. Overflow possible during conversion.
sourcefn into_i128(self) -> i128
fn into_i128(self) -> i128
Converts the value of self to i128. Overflow possible during conversion.
sourcefn into_u16(self) -> u16
fn into_u16(self) -> u16
Converts the value of self to u16. Overflow possible during conversion.
sourcefn into_u32(self) -> u32
fn into_u32(self) -> u32
Converts the value of self to u32. Overflow possible during conversion.
sourcefn into_u64(self) -> u64
fn into_u64(self) -> u64
Converts the value of self to u64. Overflow possible during conversion.
sourcefn into_usize(self) -> usize
fn into_usize(self) -> usize
Converts the value of self to usize. Overflow possible during conversion.