pub trait SaturatingAddAssign<RHS = Self> {
    fn saturating_add_assign(&mut self, other: RHS);
}
Expand description

Add a number to another number in place, saturating at the numeric bounds instead of overflowing.

Required Methods

Implementations on Foreign Types

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} x + y & \text{if} \quad m \leq x + y \leq M, \\ M & \text{if} \quad x + y > M, \\ m & \text{if} \quad x + y < m, \end{cases} $$ where $m$ is Self::MIN and $M$ is Self::MAX.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Implementors