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§
Sourcefn checked_cast_from(value: T) -> Option<Self>
fn checked_cast_from(value: T) -> Option<Self>
Converts value to this type, returning None if overflow would have occurred.
Provided Methods§
Sourceunsafe fn unchecked_cast_from(value: T) -> Self
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.
Sourcefn strict_cast_from(value: T) -> Self
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.