Trait az::OverflowingCastFrom
source · [−]pub trait OverflowingCastFrom<Src>: Sized {
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
fn overflowing_cast_from(src: Src) -> (Self, bool)
fn overflowing_cast_from(src: Src) -> (Self, bool)
OverflowingCasts the value.