Trait sp_std::ops::Rem

1.0.0 · source · []
pub trait Rem<Rhs = Self> {
    type Output;
    fn rem(self, rhs: Rhs) -> Self::Output;
}
Expand description

The remainder operator %.

Note that Rhs is Self by default, but this is not mandatory.

Examples

This example implements Rem on a SplitSlice object. After Rem is implemented, one can use the % operator to find out what the remaining elements of the slice would be after splitting it into equal slices of a given length.

use std::ops::Rem;

#[derive(PartialEq, Debug)]
struct SplitSlice<'a, T: 'a> {
    slice: &'a [T],
}

impl<'a, T> Rem<usize> for SplitSlice<'a, T> {
    type Output = Self;

    fn rem(self, modulus: usize) -> Self::Output {
        let len = self.slice.len();
        let rem = len % modulus;
        let start = len - rem;
        Self {slice: &self.slice[start..]}
    }
}

// If we were to divide &[0, 1, 2, 3, 4, 5, 6, 7] into slices of size 3,
// the remainder would be &[6, 7].
assert_eq!(SplitSlice { slice: &[0, 1, 2, 3, 4, 5, 6, 7] } % 3,
           SplitSlice { slice: &[6, 7] });

Associated Types

The resulting type after applying the % operator.

Required methods

Performs the % operation.

Example
assert_eq!(12 % 10, 2);

Implementations on Foreign Types

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0 or if self / other results in overflow.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0.

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0 or if self / other results in overflow.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0.

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0 or if self / other results in overflow.

The remainder from the division of two floats.

The remainder has the same sign as the dividend and is computed as: x - (x / y).trunc() * y.

Examples

let x: f32 = 50.50;
let y: f32 = 8.125;
let remainder = x - (x / y).trunc() * y;

// The answer to both operations is 1.75
assert_eq!(x % y, remainder);

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0 or if self / other results in overflow.

The remainder from the division of two floats.

The remainder has the same sign as the dividend and is computed as: x - (x / y).trunc() * y.

Examples

let x: f32 = 50.50;
let y: f32 = 8.125;
let remainder = x - (x / y).trunc() * y;

// The answer to both operations is 1.75
assert_eq!(x % y, remainder);

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0 or if self / other results in overflow.

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0 or if self / other results in overflow.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0.

This operation satisfies n % d == n - (n / d) * d. The result has the same sign as the left operand.

Panics

This operation will panic if other == 0.

Implementors

impl Rem<BigInt> for BigInt

impl<'a> Rem<&'a BigInt> for BigInt

impl<'a> Rem<BigInt> for &'a BigInt

impl<'a, 'b> Rem<&'b BigInt> for &'a BigInt

impl<'a> Rem<&'a u8> for BigInt

impl<'a> Rem<BigInt> for &'a u8

impl<'a> Rem<u8> for &'a BigInt

impl<'a> Rem<&'a BigInt> for u8

impl<'a, 'b> Rem<&'b u8> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b u8

impl Rem<u8> for BigInt

impl Rem<BigInt> for u8

impl<'a> Rem<&'a u16> for BigInt

impl<'a> Rem<BigInt> for &'a u16

impl<'a> Rem<u16> for &'a BigInt

impl<'a> Rem<&'a BigInt> for u16

impl<'a, 'b> Rem<&'b u16> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b u16

impl Rem<u16> for BigInt

impl Rem<BigInt> for u16

impl<'a> Rem<&'a usize> for BigInt

impl<'a> Rem<BigInt> for &'a usize

impl<'a> Rem<usize> for &'a BigInt

impl<'a> Rem<&'a BigInt> for usize

impl<'a, 'b> Rem<&'b usize> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b usize

impl Rem<usize> for BigInt

impl Rem<BigInt> for usize

impl<'a> Rem<&'a i8> for BigInt

impl<'a> Rem<BigInt> for &'a i8

impl<'a> Rem<i8> for &'a BigInt

impl<'a> Rem<&'a BigInt> for i8

impl<'a, 'b> Rem<&'b i8> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b i8

impl Rem<i8> for BigInt

impl Rem<BigInt> for i8

impl<'a> Rem<&'a i16> for BigInt

impl<'a> Rem<BigInt> for &'a i16

impl<'a> Rem<i16> for &'a BigInt

impl<'a> Rem<&'a BigInt> for i16

impl<'a, 'b> Rem<&'b i16> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b i16

impl Rem<i16> for BigInt

impl Rem<BigInt> for i16

impl<'a> Rem<&'a isize> for BigInt

impl<'a> Rem<BigInt> for &'a isize

impl<'a> Rem<isize> for &'a BigInt

impl<'a> Rem<&'a BigInt> for isize

impl<'a, 'b> Rem<&'b isize> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b isize

impl Rem<isize> for BigInt

impl Rem<BigInt> for isize

impl<'a> Rem<&'a u32> for BigInt

impl<'a> Rem<BigInt> for &'a u32

impl<'a> Rem<u32> for &'a BigInt

impl<'a> Rem<&'a BigInt> for u32

impl<'a, 'b> Rem<&'b u32> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b u32

impl<'a> Rem<&'a u64> for BigInt

impl<'a> Rem<BigInt> for &'a u64

impl<'a> Rem<u64> for &'a BigInt

impl<'a> Rem<&'a BigInt> for u64

impl<'a, 'b> Rem<&'b u64> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b u64

impl<'a> Rem<&'a u128> for BigInt

impl<'a> Rem<BigInt> for &'a u128

impl<'a> Rem<u128> for &'a BigInt

impl<'a> Rem<&'a BigInt> for u128

impl<'a, 'b> Rem<&'b u128> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b u128

impl Rem<u32> for BigInt

impl Rem<BigInt> for u32

impl Rem<u64> for BigInt

impl Rem<BigInt> for u64

impl Rem<u128> for BigInt

impl Rem<BigInt> for u128

impl<'a> Rem<&'a i32> for BigInt

impl<'a> Rem<BigInt> for &'a i32

impl<'a> Rem<i32> for &'a BigInt

impl<'a> Rem<&'a BigInt> for i32

impl<'a, 'b> Rem<&'b i32> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b i32

impl<'a> Rem<&'a i64> for BigInt

impl<'a> Rem<BigInt> for &'a i64

impl<'a> Rem<i64> for &'a BigInt

impl<'a> Rem<&'a BigInt> for i64

impl<'a, 'b> Rem<&'b i64> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b i64

impl<'a> Rem<&'a i128> for BigInt

impl<'a> Rem<BigInt> for &'a i128

impl<'a> Rem<i128> for &'a BigInt

impl<'a> Rem<&'a BigInt> for i128

impl<'a, 'b> Rem<&'b i128> for &'a BigInt

impl<'a, 'b> Rem<&'a BigInt> for &'b i128

impl Rem<i32> for BigInt

impl Rem<BigInt> for i32

impl Rem<i64> for BigInt

impl Rem<BigInt> for i64

impl Rem<i128> for BigInt

impl Rem<BigInt> for i128

impl<'a> Rem<&'a BigUint> for BigUint

impl<'a> Rem<BigUint> for &'a BigUint

impl Rem<BigUint> for BigUint

impl<'a, 'b> Rem<&'b BigUint> for &'a BigUint

impl<'a> Rem<&'a u8> for BigUint

impl<'a> Rem<BigUint> for &'a u8

impl<'a> Rem<u8> for &'a BigUint

impl<'a> Rem<&'a BigUint> for u8

impl<'a, 'b> Rem<&'b u8> for &'a BigUint

impl<'a, 'b> Rem<&'a BigUint> for &'b u8

impl Rem<u8> for BigUint

impl Rem<BigUint> for u8

impl<'a> Rem<&'a u16> for BigUint

impl<'a> Rem<BigUint> for &'a u16

impl<'a> Rem<u16> for &'a BigUint

impl<'a> Rem<&'a BigUint> for u16

impl<'a, 'b> Rem<&'b u16> for &'a BigUint

impl<'a, 'b> Rem<&'a BigUint> for &'b u16

impl Rem<u16> for BigUint

impl Rem<BigUint> for u16

impl<'a> Rem<&'a usize> for BigUint

impl<'a> Rem<BigUint> for &'a usize

impl<'a> Rem<usize> for &'a BigUint

impl<'a> Rem<&'a BigUint> for usize

impl<'a, 'b> Rem<&'b usize> for &'a BigUint

impl<'a, 'b> Rem<&'a BigUint> for &'b usize

impl Rem<usize> for BigUint

impl Rem<BigUint> for usize

impl Rem<u32> for BigUint

impl Rem<BigUint> for u32

impl<'a> Rem<&'a u32> for BigUint

impl<'a> Rem<BigUint> for &'a u32

impl<'a, 'b> Rem<&'b u32> for &'a BigUint

impl<'a, 'b> Rem<&'a BigUint> for &'b u32

impl<'a> Rem<&'a u64> for BigUint

impl<'a> Rem<BigUint> for &'a u64

impl<'a> Rem<u64> for &'a BigUint

impl<'a> Rem<&'a BigUint> for u64

impl<'a, 'b> Rem<&'b u64> for &'a BigUint

impl<'a, 'b> Rem<&'a BigUint> for &'b u64

impl<'a> Rem<&'a u128> for BigUint

impl<'a> Rem<BigUint> for &'a u128

impl<'a> Rem<u128> for &'a BigUint

impl<'a> Rem<&'a BigUint> for u128

impl<'a, 'b> Rem<&'b u128> for &'a BigUint

impl<'a, 'b> Rem<&'a BigUint> for &'b u128

impl<'a> Rem<u32> for &'a BigUint

impl<'a> Rem<&'a BigUint> for u32

impl Rem<u64> for BigUint

impl Rem<BigUint> for u64

impl Rem<u128> for BigUint

impl Rem<BigUint> for u128

impl<'a, 'b, T: Clone + Num> Rem<&'b Complex<T>> for &'a Complex<T>

impl<'a, T: Clone + Num> Rem<Complex<T>> for &'a Complex<T>

impl<'a, T: Clone + Num> Rem<&'a Complex<T>> for Complex<T>

impl<T: Clone + Num> Rem<Complex<T>> for Complex<T>

impl<T: Clone + Num> Rem<T> for Complex<T>

impl<'a, T: Clone + Num> Rem<&'a T> for Complex<T>

impl<'a, T: Clone + Num> Rem<T> for &'a Complex<T>

impl<'a, 'b, T: Clone + Num> Rem<&'a T> for &'b Complex<T>

impl<'a> Rem<&'a Complex<usize>> for usize

impl<'a> Rem<Complex<usize>> for &'a usize

impl<'a, 'b> Rem<&'a Complex<usize>> for &'b usize

impl<'a> Rem<&'a Complex<u8>> for u8

impl<'a> Rem<Complex<u8>> for &'a u8

impl<'a, 'b> Rem<&'a Complex<u8>> for &'b u8

impl<'a> Rem<&'a Complex<u16>> for u16

impl<'a> Rem<Complex<u16>> for &'a u16

impl<'a, 'b> Rem<&'a Complex<u16>> for &'b u16

impl<'a> Rem<&'a Complex<u32>> for u32

impl<'a> Rem<Complex<u32>> for &'a u32

impl<'a, 'b> Rem<&'a Complex<u32>> for &'b u32

impl<'a> Rem<&'a Complex<u64>> for u64

impl<'a> Rem<Complex<u64>> for &'a u64

impl<'a, 'b> Rem<&'a Complex<u64>> for &'b u64

impl<'a> Rem<&'a Complex<u128>> for u128

impl<'a> Rem<Complex<u128>> for &'a u128

impl<'a, 'b> Rem<&'a Complex<u128>> for &'b u128

impl<'a> Rem<&'a Complex<isize>> for isize

impl<'a> Rem<Complex<isize>> for &'a isize

impl<'a, 'b> Rem<&'a Complex<isize>> for &'b isize

impl<'a> Rem<&'a Complex<i8>> for i8

impl<'a> Rem<Complex<i8>> for &'a i8

impl<'a, 'b> Rem<&'a Complex<i8>> for &'b i8

impl<'a> Rem<&'a Complex<i16>> for i16

impl<'a> Rem<Complex<i16>> for &'a i16

impl<'a, 'b> Rem<&'a Complex<i16>> for &'b i16

impl<'a> Rem<&'a Complex<i32>> for i32

impl<'a> Rem<Complex<i32>> for &'a i32

impl<'a, 'b> Rem<&'a Complex<i32>> for &'b i32

impl<'a> Rem<&'a Complex<i64>> for i64

impl<'a> Rem<Complex<i64>> for &'a i64

impl<'a, 'b> Rem<&'a Complex<i64>> for &'b i64

impl<'a> Rem<&'a Complex<i128>> for i128

impl<'a> Rem<Complex<i128>> for &'a i128

impl<'a, 'b> Rem<&'a Complex<i128>> for &'b i128

impl<'a> Rem<&'a Complex<f32>> for f32

impl<'a> Rem<Complex<f32>> for &'a f32

impl<'a, 'b> Rem<&'a Complex<f32>> for &'b f32

impl<'a> Rem<&'a Complex<f64>> for f64

impl<'a> Rem<Complex<f64>> for &'a f64

impl<'a, 'b> Rem<&'a Complex<f64>> for &'b f64

impl Rem<Complex<usize>> for usize

impl Rem<Complex<u8>> for u8

impl Rem<Complex<u16>> for u16

impl Rem<Complex<u32>> for u32

impl Rem<Complex<u64>> for u64

impl Rem<Complex<u128>> for u128

impl Rem<Complex<isize>> for isize

impl Rem<Complex<i8>> for i8

impl Rem<Complex<i16>> for i16

impl Rem<Complex<i32>> for i32

impl Rem<Complex<i64>> for i64

impl Rem<Complex<i128>> for i128

impl Rem<Complex<f32>> for f32

impl Rem<Complex<f64>> for f64

impl<'a, 'b, T: Clone + Integer> Rem<&'b Ratio<T>> for &'a Ratio<T>

impl<'a, 'b, T: Clone + Integer> Rem<&'b T> for &'a Ratio<T>

impl<'a, T> Rem<Ratio<T>> for &'a Ratio<T> where
    T: Clone + Integer

impl<'a, T> Rem<T> for &'a Ratio<T> where
    T: Clone + Integer

impl<'a, T> Rem<&'a Ratio<T>> for Ratio<T> where
    T: Clone + Integer

impl<'a, T> Rem<&'a T> for Ratio<T> where
    T: Clone + Integer

impl<T: Clone + Integer> Rem<Ratio<T>> for Ratio<T>

impl<T: Clone + Integer> Rem<T> for Ratio<T>

impl<T> Rem<T> for U128 where
    T: Into<U128> + Copy

impl<'a, T> Rem<T> for &'a U128 where
    T: Into<U128> + Copy

impl<T> Rem<T> for U256 where
    T: Into<U256> + Copy

impl<'a, T> Rem<T> for &'a U256 where
    T: Into<U256> + Copy

impl<T> Rem<T> for U512 where
    T: Into<U512> + Copy

impl<'a, T> Rem<T> for &'a U512 where
    T: Into<U512> + Copy

impl<I: Integer + NonZero> Rem<I> for Z0

impl<Ul: Unsigned + NonZero, Ur: Unsigned + NonZero> Rem<PInt<Ur>> for PInt<Ul> where
    Ul: Rem<Ur>,
    PInt<Ul>: PrivateRem<<Ul as Rem<Ur>>::Output, PInt<Ur>>, 

impl<Ul: Unsigned + NonZero, Ur: Unsigned + NonZero> Rem<NInt<Ur>> for PInt<Ul> where
    Ul: Rem<Ur>,
    PInt<Ul>: PrivateRem<<Ul as Rem<Ur>>::Output, NInt<Ur>>, 

impl<Ul: Unsigned + NonZero, Ur: Unsigned + NonZero> Rem<PInt<Ur>> for NInt<Ul> where
    Ul: Rem<Ur>,
    NInt<Ul>: PrivateRem<<Ul as Rem<Ur>>::Output, PInt<Ur>>, 

impl<Ul: Unsigned + NonZero, Ur: Unsigned + NonZero> Rem<NInt<Ur>> for NInt<Ul> where
    Ul: Rem<Ur>,
    NInt<Ul>: PrivateRem<<Ul as Rem<Ur>>::Output, NInt<Ur>>, 

impl<Ur: Unsigned, Br: Bit> Rem<UInt<Ur, Br>> for UTerm

impl<Ul: Unsigned, Bl: Bit, Ur: Unsigned, Br: Bit> Rem<UInt<Ur, Br>> for UInt<Ul, Bl> where
    UInt<Ul, Bl>: Len,
    Length<UInt<Ul, Bl>>: Sub<B1>,
    (): PrivateDiv<UInt<Ul, Bl>, UInt<Ur, Br>, U0, U0, Sub1<Length<UInt<Ul, Bl>>>>, 

impl<Rhs> Rem<Rhs> for ATerm

impl<V, A, Rhs> Rem<Rhs> for TArr<V, A> where
    V: Rem<Rhs>,
    A: Rem<Rhs>,
    Rhs: Copy

impl<T: Into<F32>> Rem<T> for F32

impl<T: Into<F64>> Rem<T> for F64