# Trait core::ops::Rem 1.0.0 [−] [src]

    #[lang = "rem"]
    pub trait Rem<RHS = Self> {
        type Output = Self;
        fn rem(self, rhs: RHS) -> Self::Output;
    }

The remainder operator `%`.

# 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 = SplitSlice<'a, T>;

        fn rem(self, modulus: usize) -> Self {
            let len = self.slice.len();
            let rem = len % modulus;
            let start = len - rem;
            SplitSlice {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] });Run

## Associated Types

### `type Output = Self`

The resulting type after applying the `%` operator

## Required Methods

### `fn rem(self, rhs: RHS) -> Self::Output`

The method for the `%` operator

## Implementors

- `impl Rem for Wrapping<usize>`
- `impl<'a> Rem<Wrapping<usize>> for &'a Wrapping<usize>`
- `impl<'a> Rem<&'a Wrapping<usize>> for Wrapping<usize>`
- `impl<'a, 'b> Rem<&'a Wrapping<usize>> for &'b Wrapping<usize>`
- `impl Rem for Wrapping<u8>`
- `impl<'a> Rem<Wrapping<u8>> for &'a Wrapping<u8>`
- `impl<'a> Rem<&'a Wrapping<u8>> for Wrapping<u8>`
- `impl<'a, 'b> Rem<&'a Wrapping<u8>> for &'b Wrapping<u8>`
- `impl Rem for Wrapping<u16>`
- `impl<'a> Rem<Wrapping<u16>> for &'a Wrapping<u16>`
- `impl<'a> Rem<&'a Wrapping<u16>> for Wrapping<u16>`
- `impl<'a, 'b> Rem<&'a Wrapping<u16>> for &'b Wrapping<u16>`
- `impl Rem for Wrapping<u32>`
- `impl<'a> Rem<Wrapping<u32>> for &'a Wrapping<u32>`
- `impl<'a> Rem<&'a Wrapping<u32>> for Wrapping<u32>`
- `impl<'a, 'b> Rem<&'a Wrapping<u32>> for &'b Wrapping<u32>`
- `impl Rem for Wrapping<u64>`
- `impl<'a> Rem<Wrapping<u64>> for &'a Wrapping<u64>`
- `impl<'a> Rem<&'a Wrapping<u64>> for Wrapping<u64>`
- `impl<'a, 'b> Rem<&'a Wrapping<u64>> for &'b Wrapping<u64>`
- `impl Rem for Wrapping<u128>`
- `impl<'a> Rem<Wrapping<u128>> for &'a Wrapping<u128>`
- `impl<'a> Rem<&'a Wrapping<u128>> for Wrapping<u128>`
- `impl<'a, 'b> Rem<&'a Wrapping<u128>> for &'b Wrapping<u128>`
- `impl Rem for Wrapping<isize>`
- `impl<'a> Rem<Wrapping<isize>> for &'a Wrapping<isize>`
- `impl<'a> Rem<&'a Wrapping<isize>> for Wrapping<isize>`
- `impl<'a, 'b> Rem<&'a Wrapping<isize>> for &'b Wrapping<isize>`
- `impl Rem for Wrapping<i8>`
- `impl<'a> Rem<Wrapping<i8>> for &'a Wrapping<i8>`
- `impl<'a> Rem<&'a Wrapping<i8>> for Wrapping<i8>`
- `impl<'a, 'b> Rem<&'a Wrapping<i8>> for &'b Wrapping<i8>`
- `impl Rem for Wrapping<i16>`
- `impl<'a> Rem<Wrapping<i16>> for &'a Wrapping<i16>`
- `impl<'a> Rem<&'a Wrapping<i16>> for Wrapping<i16>`
- `impl<'a, 'b> Rem<&'a Wrapping<i16>> for &'b Wrapping<i16>`
- `impl Rem for Wrapping<i32>`
- `impl<'a> Rem<Wrapping<i32>> for &'a Wrapping<i32>`
- `impl<'a> Rem<&'a Wrapping<i32>> for Wrapping<i32>`
- `impl<'a, 'b> Rem<&'a Wrapping<i32>> for &'b Wrapping<i32>`
- `impl Rem for Wrapping<i64>`
- `impl<'a> Rem<Wrapping<i64>> for &'a Wrapping<i64>`
- `impl<'a> Rem<&'a Wrapping<i64>> for Wrapping<i64>`
- `impl<'a, 'b> Rem<&'a Wrapping<i64>> for &'b Wrapping<i64>`
- `impl Rem for Wrapping<i128>`
- `impl<'a> Rem<Wrapping<i128>> for &'a Wrapping<i128>`
- `impl<'a> Rem<&'a Wrapping<i128>> for Wrapping<i128>`
- `impl<'a, 'b> Rem<&'a Wrapping<i128>> for &'b Wrapping<i128>`
- `impl Rem for usize`
- `impl<'a> Rem<usize> for &'a usize`
- `impl<'a> Rem<&'a usize> for usize`
- `impl<'a, 'b> Rem<&'a usize> for &'b usize`
- `impl Rem for u8`
- `impl<'a> Rem<u8> for &'a u8`
- `impl<'a> Rem<&'a u8> for u8`
- `impl<'a, 'b> Rem<&'a u8> for &'b u8`
- `impl Rem for u16`
- `impl<'a> Rem<u16> for &'a u16`
- `impl<'a> Rem<&'a u16> for u16`
- `impl<'a, 'b> Rem<&'a u16> for &'b u16`
- `impl Rem for u32`
- `impl<'a> Rem<u32> for &'a u32`
- `impl<'a> Rem<&'a u32> for u32`
- `impl<'a, 'b> Rem<&'a u32> for &'b u32`
- `impl Rem for u64`
- `impl<'a> Rem<u64> for &'a u64`
- `impl<'a> Rem<&'a u64> for u64`
- `impl<'a, 'b> Rem<&'a u64> for &'b u64`
- `impl Rem for u128`
- `impl<'a> Rem<u128> for &'a u128`
- `impl<'a> Rem<&'a u128> for u128`
- `impl<'a, 'b> Rem<&'a u128> for &'b u128`
- `impl Rem for isize`
- `impl<'a> Rem<isize> for &'a isize`
- `impl<'a> Rem<&'a isize> for isize`
- `impl<'a, 'b> Rem<&'a isize> for &'b isize`
- `impl Rem for i8`
- `impl<'a> Rem<i8> for &'a i8`
- `impl<'a> Rem<&'a i8> for i8`
- `impl<'a, 'b> Rem<&'a i8> for &'b i8`
- `impl Rem for i16`
- `impl<'a> Rem<i16> for &'a i16`
- `impl<'a> Rem<&'a i16> for i16`
- `impl<'a, 'b> Rem<&'a i16> for &'b i16`
- `impl Rem for i32`
- `impl<'a> Rem<i32> for &'a i32`
- `impl<'a> Rem<&'a i32> for i32`
- `impl<'a, 'b> Rem<&'a i32> for &'b i32`
- `impl Rem for i64`
- `impl<'a> Rem<i64> for &'a i64`
- `impl<'a> Rem<&'a i64> for i64`
- `impl<'a, 'b> Rem<&'a i64> for &'b i64`
- `impl Rem for i128`
- `impl<'a> Rem<i128> for &'a i128`
- `impl<'a> Rem<&'a i128> for i128`
- `impl<'a, 'b> Rem<&'a i128> for &'b i128`
- `impl Rem for f32`
- `impl<'a> Rem<f32> for &'a f32`
- `impl<'a> Rem<&'a f32> for f32`
- `impl<'a, 'b> Rem<&'a f32> for &'b f32`
- `impl Rem for f64`
- `impl<'a> Rem<f64> for &'a f64`
- `impl<'a> Rem<&'a f64> for f64`
- `impl<'a, 'b> Rem<&'a f64> for &'b f64`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)