pub trait Rem<Rhs = Self> { typeOutput; // Required method fnrem(self, rhs: Rhs) -> Self::Output;}Expand description
The remainder operator%.
Note thatRhs isSelf by default, but this is not mandatory.
§Examples
This example implementsRem on aSplitSlice object. AfterRem isimplemented, one can use the% operator to find out what the remainingelements of the slice would be after splitting it into equal slices of agiven length.
usestd::ops::Rem;#[derive(PartialEq, Debug)]structSplitSlice<'a, T> { slice:&'a[T],}impl<'a, T> Rem<usize>forSplitSlice<'a, T> {typeOutput =Self;fnrem(self, modulus: usize) ->Self::Output {letlen =self.slice.len();letrem = len % modulus;letstart = 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] });Required Associated Types§
Required Methods§
Implementors§
1.0.0 (const:unstable) ·Source§implRem forf16
The remainder from the division of two floats.
implRem forf16
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
1.0.0 (const:unstable) ·Source§implRem forf32
The remainder from the division of two floats.
implRem forf32
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
1.0.0 (const:unstable) ·Source§implRem forf64
The remainder from the division of two floats.
implRem forf64
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
1.0.0 (const:unstable) ·Source§implRem forf128
The remainder from the division of two floats.
implRem forf128
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
1.0.0 (const:unstable) ·Source§implRem fori8
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem fori8
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0 or ifself / other results in overflow.
1.0.0 (const:unstable) ·Source§implRem fori16
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem fori16
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0 or ifself / other results in overflow.
1.0.0 (const:unstable) ·Source§implRem fori32
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem fori32
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0 or ifself / other results in overflow.
1.0.0 (const:unstable) ·Source§implRem fori64
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem fori64
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0 or ifself / other results in overflow.
1.0.0 (const:unstable) ·Source§implRem fori128
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem fori128
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0 or ifself / other results in overflow.
1.0.0 (const:unstable) ·Source§implRem forisize
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem forisize
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0 or ifself / other results in overflow.
1.0.0 (const:unstable) ·Source§implRem foru8
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem foru8
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0.
1.0.0 (const:unstable) ·Source§implRem foru16
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem foru16
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0.
1.0.0 (const:unstable) ·Source§implRem foru32
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem foru32
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0.
1.0.0 (const:unstable) ·Source§implRem foru64
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem foru64
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0.
1.0.0 (const:unstable) ·Source§implRem foru128
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem foru128
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0.
1.0.0 (const:unstable) ·Source§implRem forusize
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
implRem forusize
This operation satisfiesn % d == n - (n / d) * d. Theresult has the same sign as the left operand.
§Panics
This operation will panic ifother == 0.