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§
sourcefn wrapping_cast_from(src: Src) -> Self
fn wrapping_cast_from(src: Src) -> Self
Casts the value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.