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

Subtracts a number by another number in place, saturating at the numeric bounds instead of overflowing.

Required Methods

Implementations on Foreign Types

Subtracts a number by 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.

Subtracts a number by 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.

Subtracts a number by 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.

Subtracts a number by 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.

Subtracts a number by 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.

Subtracts a number by 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.

Subtracts a number by 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.

Subtracts a number by 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.

Subtracts a number by 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.

Subtracts a number by 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.

Subtracts a number by 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.

Subtracts a number by 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