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ยง
Sourcefn checked_cast_from(value: T) -> Option<Self>
๐ฌThis is a nightly-only experimental API. (integer_casts #157388)
fn checked_cast_from(value: T) -> Option<Self>
integer_casts #157388)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 #157388)
unsafe fn unchecked_cast_from(value: T) -> Self
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.
Sourcefn strict_cast_from(value: T) -> Self
๐ฌThis is a nightly-only experimental API. (integer_casts #157388)
fn strict_cast_from(value: T) -> Self
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".