pub trait CheckedCastFrom<Src>: Sized {
    fn checked_cast_from(src: Src) -> Option<Self>;
Expand description

Used for checked casts.

This trait enables trait constraints for casting in the opposite direction to CheckedCast.


use az::CheckedCastFrom;
trait Tr {
    type Assoc: CheckedCastFrom<u8>;
    fn checked_assoc_from_u8(a: u8) -> Option<Self::Assoc> {
impl Tr for () {
    type Assoc = i8;
assert_eq!(<() as Tr>::checked_assoc_from_u8(5u8), Some(5i8));
assert_eq!(<() as Tr>::checked_assoc_from_u8(255u8), None);

Required Methods

Casts the value.