pub trait CheckedAdd: Sized + Add<Output = Self> {
// Required method
fn checked_add(&self, v: &Self) -> Option<Self>;
}
Expand description
Performs addition that returns None
instead of wrapping around on
overflow.
Required Methods§
Sourcefn checked_add(&self, v: &Self) -> Option<Self>
fn checked_add(&self, v: &Self) -> Option<Self>
Adds two numbers, checking for overflow. If overflow happens, None
is
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.