pub trait CastFrom<Src> {
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);