Skip to main content

CheckedCastFromInt

Trait CheckedCastFromInt 

Source
pub trait CheckedCastFromInt<T>: SealedCast<T> {
    // Required method
    fn checked_cast_from(value: T) -> Option<Self>;

    // Provided methods
    unsafe fn unchecked_cast_from(value: T) -> Self { ... }
    fn strict_cast_from(value: T) -> Self { ... }
}
Expand description

Fallible conversion between integers.

Required Methods§

Source

fn checked_cast_from(value: T) -> Option<Self>

Converts value to this type, returning None if overflow would have occurred.

Provided Methods§

Source

unsafe fn unchecked_cast_from(value: T) -> Self

Converts value to this type, assuming overflow cannot occur.

§Safety

This results in undefined behavior when value will overflow when converted to this type.

Source

fn strict_cast_from(value: T) -> Self

Converts value to this type, panicking on overflow.

§Panics

This function will always panic on overflow, regardless of whether overflow checks are enabled.

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.

Implementations on Foreign Types§

Source§

impl CheckedCastFromInt<i8> for i8

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for i16

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for i32

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for i64

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for i128

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for isize

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for u8

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for u16

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for u32

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for u64

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for u128

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i8> for usize

Source§

fn checked_cast_from(value: i8) -> Option<Self>

Source§

impl CheckedCastFromInt<i16> for i8

Source§

impl CheckedCastFromInt<i16> for i16

Source§

impl CheckedCastFromInt<i16> for i32

Source§

impl CheckedCastFromInt<i16> for i64

Source§

impl CheckedCastFromInt<i16> for i128

Source§

impl CheckedCastFromInt<i16> for isize

Source§

impl CheckedCastFromInt<i16> for u8

Source§

impl CheckedCastFromInt<i16> for u16

Source§

impl CheckedCastFromInt<i16> for u32

Source§

impl CheckedCastFromInt<i16> for u64

Source§

impl CheckedCastFromInt<i16> for u128

Source§

impl CheckedCastFromInt<i16> for usize

Source§

impl CheckedCastFromInt<i32> for i8

Source§

impl CheckedCastFromInt<i32> for i16

Source§

impl CheckedCastFromInt<i32> for i32

Source§

impl CheckedCastFromInt<i32> for i64

Source§

impl CheckedCastFromInt<i32> for i128

Source§

impl CheckedCastFromInt<i32> for isize

Source§

impl CheckedCastFromInt<i32> for u8

Source§

impl CheckedCastFromInt<i32> for u16

Source§

impl CheckedCastFromInt<i32> for u32

Source§

impl CheckedCastFromInt<i32> for u64

Source§

impl CheckedCastFromInt<i32> for u128

Source§

impl CheckedCastFromInt<i32> for usize

Source§

impl CheckedCastFromInt<i64> for i8

Source§

impl CheckedCastFromInt<i64> for i16

Source§

impl CheckedCastFromInt<i64> for i32

Source§

impl CheckedCastFromInt<i64> for i64

Source§

impl CheckedCastFromInt<i64> for i128

Source§

impl CheckedCastFromInt<i64> for isize

Source§

impl CheckedCastFromInt<i64> for u8

Source§

impl CheckedCastFromInt<i64> for u16

Source§

impl CheckedCastFromInt<i64> for u32

Source§

impl CheckedCastFromInt<i64> for u64

Source§

impl CheckedCastFromInt<i64> for u128

Source§

impl CheckedCastFromInt<i64> for usize

Source§

impl CheckedCastFromInt<i128> for i8

Source§

impl CheckedCastFromInt<i128> for i16

Source§

impl CheckedCastFromInt<i128> for i32

Source§

impl CheckedCastFromInt<i128> for i64

Source§

impl CheckedCastFromInt<i128> for i128

Source§

impl CheckedCastFromInt<i128> for isize

Source§

impl CheckedCastFromInt<i128> for u8

Source§

impl CheckedCastFromInt<i128> for u16

Source§

impl CheckedCastFromInt<i128> for u32

Source§

impl CheckedCastFromInt<i128> for u64

Source§

impl CheckedCastFromInt<i128> for u128

Source§

impl CheckedCastFromInt<i128> for usize

Source§

impl CheckedCastFromInt<isize> for i8

Source§

impl CheckedCastFromInt<isize> for i16

Source§

impl CheckedCastFromInt<isize> for i32

Source§

impl CheckedCastFromInt<isize> for i64

Source§

impl CheckedCastFromInt<isize> for i128

Source§

impl CheckedCastFromInt<isize> for isize

Source§

impl CheckedCastFromInt<isize> for u8

Source§

impl CheckedCastFromInt<isize> for u16

Source§

impl CheckedCastFromInt<isize> for u32

Source§

impl CheckedCastFromInt<isize> for u64

Source§

impl CheckedCastFromInt<isize> for u128

Source§

impl CheckedCastFromInt<isize> for usize

Source§

impl CheckedCastFromInt<u8> for i8

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for i16

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for i32

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for i64

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for i128

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for isize

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for u8

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for u16

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for u32

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for u64

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for u128

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u8> for usize

Source§

fn checked_cast_from(value: u8) -> Option<Self>

Source§

impl CheckedCastFromInt<u16> for i8

Source§

impl CheckedCastFromInt<u16> for i16

Source§

impl CheckedCastFromInt<u16> for i32

Source§

impl CheckedCastFromInt<u16> for i64

Source§

impl CheckedCastFromInt<u16> for i128

Source§

impl CheckedCastFromInt<u16> for isize

Source§

impl CheckedCastFromInt<u16> for u8

Source§

impl CheckedCastFromInt<u16> for u16

Source§

impl CheckedCastFromInt<u16> for u32

Source§

impl CheckedCastFromInt<u16> for u64

Source§

impl CheckedCastFromInt<u16> for u128

Source§

impl CheckedCastFromInt<u16> for usize

Source§

impl CheckedCastFromInt<u32> for i8

Source§

impl CheckedCastFromInt<u32> for i16

Source§

impl CheckedCastFromInt<u32> for i32

Source§

impl CheckedCastFromInt<u32> for i64

Source§

impl CheckedCastFromInt<u32> for i128

Source§

impl CheckedCastFromInt<u32> for isize

Source§

impl CheckedCastFromInt<u32> for u8

Source§

impl CheckedCastFromInt<u32> for u16

Source§

impl CheckedCastFromInt<u32> for u32

Source§

impl CheckedCastFromInt<u32> for u64

Source§

impl CheckedCastFromInt<u32> for u128

Source§

impl CheckedCastFromInt<u32> for usize

Source§

impl CheckedCastFromInt<u64> for i8

Source§

impl CheckedCastFromInt<u64> for i16

Source§

impl CheckedCastFromInt<u64> for i32

Source§

impl CheckedCastFromInt<u64> for i64

Source§

impl CheckedCastFromInt<u64> for i128

Source§

impl CheckedCastFromInt<u64> for isize

Source§

impl CheckedCastFromInt<u64> for u8

Source§

impl CheckedCastFromInt<u64> for u16

Source§

impl CheckedCastFromInt<u64> for u32

Source§

impl CheckedCastFromInt<u64> for u64

Source§

impl CheckedCastFromInt<u64> for u128

Source§

impl CheckedCastFromInt<u64> for usize

Source§

impl CheckedCastFromInt<u128> for i8

Source§

impl CheckedCastFromInt<u128> for i16

Source§

impl CheckedCastFromInt<u128> for i32

Source§

impl CheckedCastFromInt<u128> for i64

Source§

impl CheckedCastFromInt<u128> for i128

Source§

impl CheckedCastFromInt<u128> for isize

Source§

impl CheckedCastFromInt<u128> for u8

Source§

impl CheckedCastFromInt<u128> for u16

Source§

impl CheckedCastFromInt<u128> for u32

Source§

impl CheckedCastFromInt<u128> for u64

Source§

impl CheckedCastFromInt<u128> for u128

Source§

impl CheckedCastFromInt<u128> for usize

Source§

impl CheckedCastFromInt<usize> for i8

Source§

impl CheckedCastFromInt<usize> for i16

Source§

impl CheckedCastFromInt<usize> for i32

Source§

impl CheckedCastFromInt<usize> for i64

Source§

impl CheckedCastFromInt<usize> for i128

Source§

impl CheckedCastFromInt<usize> for isize

Source§

impl CheckedCastFromInt<usize> for u8

Source§

impl CheckedCastFromInt<usize> for u16

Source§

impl CheckedCastFromInt<usize> for u32

Source§

impl CheckedCastFromInt<usize> for u64

Source§

impl CheckedCastFromInt<usize> for u128

Source§

impl CheckedCastFromInt<usize> for usize

Implementors§