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§

source

fn into_i8(self) -> i8

Converts the value of self to i8. Overflow possible during conversion.

source

fn into_i16(self) -> i16

Converts the value of self to i16. Overflow possible during conversion.

source

fn into_i32(self) -> i32

Converts the value of self to i32. Overflow possible during conversion.

source

fn into_i64(self) -> i64

Converts the value of self to i64. Overflow possible during conversion.

source

fn into_isize(self) -> isize

Converts the value of self to isize. Overflow possible during conversion.

source

fn into_i128(self) -> i128

Converts the value of self to i128. Overflow possible during conversion.

source

fn into_u8(self) -> u8

Converts the value of self to u8. Overflow possible during conversion.

source

fn into_u16(self) -> u16

Converts the value of self to u16. Overflow possible during conversion.

source

fn into_u32(self) -> u32

Converts the value of self to u32. Overflow possible during conversion.

source

fn into_u64(self) -> u64

Converts the value of self to u64. Overflow possible during conversion.

source

fn into_usize(self) -> usize

Converts the value of self to usize. Overflow possible during conversion.

source

fn into_u128(self) -> u128

Converts the value of self to u128.

Implementations on Foreign Types§

source§

impl CastIntoAs for u16

source§

impl CastIntoAs for i8

source§

impl CastIntoAs for u64

source§

impl CastIntoAs for usize

source§

impl CastIntoAs for u8

source§

impl CastIntoAs for i64

source§

impl CastIntoAs for u128

source§

impl CastIntoAs for i16

source§

impl CastIntoAs for isize

source§

impl CastIntoAs for i128

source§

impl CastIntoAs for i32

source§

impl CastIntoAs for u32

Implementors§