Trait az::WrappingCastFrom

source ·
pub trait WrappingCastFrom<Src> {
    // Required method
    fn wrapping_cast_from(src: Src) -> Self;
}
Expand description

Wrapping cast.

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

Examples

use az::WrappingCastFrom;
trait Tr {
    type Assoc: WrappingCastFrom<u8>;
    fn wrapping_assoc_from_u8(a: u8) -> Self::Assoc {
        WrappingCastFrom::wrapping_cast_from(a)
    }
}
impl Tr for () {
    type Assoc = i8;
}
assert_eq!(<() as Tr>::wrapping_assoc_from_u8(5u8), 5i8);
assert_eq!(<() as Tr>::wrapping_assoc_from_u8(255u8), -1i8);

Required Methods§

source

fn wrapping_cast_from(src: Src) -> Self

Casts the value.

Implementors§

source§

impl<Src: WrappingCast<Dst>, Dst> WrappingCastFrom<Src> for Dst