pub trait OverflowingCastFrom<Src>: Sized {
// Required method
fn overflowing_cast_from(src: Src) -> (Self, bool);
}
Expand description
Used for overflowing casts.
This trait enables trait constraints for casting in the opposite direction to
OverflowingCast
.
§Examples
use az::OverflowingCastFrom;
trait Tr {
type Assoc: OverflowingCastFrom<u8>;
fn overflowing_assoc_from_u8(a: u8) -> (Self::Assoc, bool) {
OverflowingCastFrom::overflowing_cast_from(a)
}
}
impl Tr for () {
type Assoc = i8;
}
assert_eq!(<() as Tr>::overflowing_assoc_from_u8(5u8), (5i8, false));
assert_eq!(<() as Tr>::overflowing_assoc_from_u8(255u8), (-1i8, true));
Required Methods§
sourcefn overflowing_cast_from(src: Src) -> (Self, bool)
fn overflowing_cast_from(src: Src) -> (Self, bool)
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.