Trait DefensiveSaturating
pub trait DefensiveSaturating {
// Required methods
fn defensive_saturating_add(self, other: Self) -> Self;
fn defensive_saturating_sub(self, other: Self) -> Self;
fn defensive_saturating_mul(self, other: Self) -> Self;
fn defensive_saturating_accrue(&mut self, other: Self);
fn defensive_saturating_reduce(&mut self, other: Self);
fn defensive_saturating_inc(&mut self);
fn defensive_saturating_dec(&mut self);
}
Expand description
A variant of Defensive
with the same rationale, for the arithmetic operations where in
case an infallible operation fails, it saturates.
Required Methods§
fn defensive_saturating_add(self, other: Self) -> Self
fn defensive_saturating_add(self, other: Self) -> Self
Return self
plus other
defensively.
fn defensive_saturating_sub(self, other: Self) -> Self
fn defensive_saturating_sub(self, other: Self) -> Self
Return self
minus other
defensively.
fn defensive_saturating_mul(self, other: Self) -> Self
fn defensive_saturating_mul(self, other: Self) -> Self
Return the product of self
and other
defensively.
fn defensive_saturating_accrue(&mut self, other: Self)
fn defensive_saturating_accrue(&mut self, other: Self)
Increase self
by other
defensively.
fn defensive_saturating_reduce(&mut self, other: Self)
fn defensive_saturating_reduce(&mut self, other: Self)
Reduce self
by other
defensively.
fn defensive_saturating_inc(&mut self)
fn defensive_saturating_inc(&mut self)
Increment self
by one defensively.
fn defensive_saturating_dec(&mut self)
fn defensive_saturating_dec(&mut self)
Decrement self
by one defensively.
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.