Skip to main content

CheckedCastFromInt

Trait CheckedCastFromInt 

Source
pub trait CheckedCastFromInt<T>: Sized {
    // Required methods
    fn checked_cast_from(value: T) -> Option<Self>;
    unsafe fn unchecked_cast_from(value: T) -> Self;
    fn strict_cast_from(value: T) -> Self;
}
๐Ÿ”ฌThis is a nightly-only experimental API. (integer_casts #157388)
Expand description

Fallible conversion between integers.

This trait cannot be implemented outside core.

Required Methodsยง

Source

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

๐Ÿ”ฌThis is a nightly-only experimental API. (integer_casts #157388)

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

Source

unsafe fn unchecked_cast_from(value: T) -> Self

๐Ÿ”ฌThis is a nightly-only experimental API. (integer_casts #157388)

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

๐Ÿ”ฌThis is a nightly-only experimental API. (integer_casts #157388)

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".

Implementorsยง

Sourceยง

impl CheckedCastFromInt<i8> for i8

Sourceยง

impl CheckedCastFromInt<i8> for i16

Sourceยง

impl CheckedCastFromInt<i8> for i32

Sourceยง

impl CheckedCastFromInt<i8> for i64

Sourceยง

impl CheckedCastFromInt<i8> for i128

Sourceยง

impl CheckedCastFromInt<i8> for isize

Sourceยง

impl CheckedCastFromInt<i8> for u8

Sourceยง

impl CheckedCastFromInt<i8> for u16

Sourceยง

impl CheckedCastFromInt<i8> for u32

Sourceยง

impl CheckedCastFromInt<i8> for u64

Sourceยง

impl CheckedCastFromInt<i8> for u128

Sourceยง

impl CheckedCastFromInt<i8> for usize

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ยง

impl CheckedCastFromInt<u8> for i16

Sourceยง

impl CheckedCastFromInt<u8> for i32

Sourceยง

impl CheckedCastFromInt<u8> for i64

Sourceยง

impl CheckedCastFromInt<u8> for i128

Sourceยง

impl CheckedCastFromInt<u8> for isize

Sourceยง

impl CheckedCastFromInt<u8> for u8

Sourceยง

impl CheckedCastFromInt<u8> for u16

Sourceยง

impl CheckedCastFromInt<u8> for u32

Sourceยง

impl CheckedCastFromInt<u8> for u64

Sourceยง

impl CheckedCastFromInt<u8> for u128

Sourceยง

impl CheckedCastFromInt<u8> for usize

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