pub trait CheckedAddUnsigned: Sized {
type Unsigned;
type Output;
// Required method
fn checked_add_unsigned(self, rhs: Self::Unsigned) -> Option<Self::Output>;
}Expand description
Checked addition of an unsigned value to a signed value.
Required Associated Types§
Required Methods§
Sourcefn checked_add_unsigned(self, rhs: Self::Unsigned) -> Option<Self::Output>
fn checked_add_unsigned(self, rhs: Self::Unsigned) -> Option<Self::Output>
Computes self + rhs, returning None if overflow occurred.
use const_num_traits::CheckedAddUnsigned;
assert_eq!(CheckedAddUnsigned::checked_add_unsigned(1i8, 2), Some(3));
assert_eq!(CheckedAddUnsigned::checked_add_unsigned(i8::MAX, 1), None);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".