Trait az::CastFrom

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

Used to cast values.

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

§Examples

use az::CastFrom;
trait Tr {
    type Assoc: CastFrom<u8>;
    fn assoc_from_u8(a: u8) -> Self::Assoc {
        CastFrom::cast_from(a)
    }
}
impl Tr for () {
    type Assoc = i8;
}
assert_eq!(<() as Tr>::assoc_from_u8(5u8), 5i8);

Required Methods§

source

fn cast_from(src: Src) -> Self

Casts the value.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Src: Cast<Dst>, Dst> CastFrom<Src> for Dst