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 trait cannot be implemented outside
core.🔬This is a nightly-only experimental API. (
integer_casts)Available on crate features
crypto and std only.Expand description
Fallible conversion between integers.
Required Methods§
Sourcefn checked_cast_from(value: T) -> Option<Self>
🔬This is a nightly-only experimental API. (integer_casts)
fn checked_cast_from(value: T) -> Option<Self>
integer_casts)Converts value to this type, returning None if overflow would have occurred.
Sourceunsafe fn unchecked_cast_from(value: T) -> Self
🔬This is a nightly-only experimental API. (integer_casts)
unsafe fn unchecked_cast_from(value: T) -> Self
integer_casts)Converts value to this type, assuming overflow cannot occur.
§Safety
This results in undefined behavior when value will overflow when
converted to this type.
Sourcefn strict_cast_from(value: T) -> Self
🔬This is a nightly-only experimental API. (integer_casts)
fn strict_cast_from(value: T) -> Self
integer_casts)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".