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.
Object Safety§
This trait is not object safe.