Skip to main content

Mod

Trait Mod 

Source
pub trait Mod<RHS = Self> {
    type Output;

    // Required method
    fn mod_op(self, other: RHS) -> Self::Output;
}
Expand description

Divides a number by another number, returning just the remainder. The remainder has the same sign as the divisor (second number).

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq |r| < |y|$.

Required Associated Types§

Required Methods§

Source

fn mod_op(self, other: RHS) -> Self::Output

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Mod for i8

Source§

fn mod_op(self, other: i8) -> i8

Divides a number by another number, returning just the remainder. The remainder has the same sign as the second number.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq |r| < |y|$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = i8

Source§

impl Mod for i16

Source§

fn mod_op(self, other: i16) -> i16

Divides a number by another number, returning just the remainder. The remainder has the same sign as the second number.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq |r| < |y|$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = i16

Source§

impl Mod for i32

Source§

fn mod_op(self, other: i32) -> i32

Divides a number by another number, returning just the remainder. The remainder has the same sign as the second number.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq |r| < |y|$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = i32

Source§

impl Mod for i64

Source§

fn mod_op(self, other: i64) -> i64

Divides a number by another number, returning just the remainder. The remainder has the same sign as the second number.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq |r| < |y|$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = i64

Source§

impl Mod for i128

Source§

fn mod_op(self, other: i128) -> i128

Divides a number by another number, returning just the remainder. The remainder has the same sign as the second number.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq |r| < |y|$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = i128

Source§

impl Mod for isize

Source§

fn mod_op(self, other: isize) -> isize

Divides a number by another number, returning just the remainder. The remainder has the same sign as the second number.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq |r| < |y|$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = isize

Source§

impl Mod for u8

Source§

fn mod_op(self, other: u8) -> u8

Divides a number by another number, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq r < y$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = u8

Source§

impl Mod for u16

Source§

fn mod_op(self, other: u16) -> u16

Divides a number by another number, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq r < y$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = u16

Source§

impl Mod for u32

Source§

fn mod_op(self, other: u32) -> u32

Divides a number by another number, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq r < y$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = u32

Source§

impl Mod for u64

Source§

fn mod_op(self, other: u64) -> u64

Divides a number by another number, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq r < y$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = u64

Source§

impl Mod for u128

Source§

fn mod_op(self, other: u128) -> u128

Divides a number by another number, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq r < y$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = u128

Source§

impl Mod for usize

Source§

fn mod_op(self, other: usize) -> usize

Divides a number by another number, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \leq r < y$.

$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor. $$

This function is called mod_op rather than mod because mod is a Rust keyword.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is 0.

§Examples

See here.

Source§

type Output = usize

Implementors§