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