pub trait CheckedAdd<T>: Sized {
type Output;
// Required method
fn checked_add(&self, rhs: T) -> Option<Self::Output>;
}Expand description
Safe addition.
Required Associated Types§
Required Methods§
Sourcefn checked_add(&self, rhs: T) -> Option<Self::Output>
fn checked_add(&self, rhs: T) -> Option<Self::Output>
Adds two items.
- If the addition occurs succesfully, then
Some<Self>is returned. - If the addition would overflow,
Noneis returned.
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.