Trait CheckedCastFromInt

pub trait CheckedCastFromInt<T>: Sized

Fallible conversion between integers.

Required Methods

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

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

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.

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.

Implementors