Trait std::ops::RemStable [-] [+] [src]

pub trait Rem<RHS = Self> where <Self as Rem<RHS>>::Output: Sized {
    type Output;

    fn rem(self, rhs: RHS) -> <Self as Rem<RHS>>::Output;
}

The Rem trait is used to specify the functionality of %.

Example

A trivial implementation of Rem. When Foo % Foo happens, it ends up calling rem, and therefore, main prints Remainder-ing!.

use std::ops::Rem; #[derive(Copy)] struct Foo; impl Rem for Foo { type Output = Foo; fn rem(self, _rhs: Foo) -> Foo { println!("Remainder-ing!"); self } } fn main() { Foo % Foo; }
use std::ops::Rem;

#[derive(Copy)]
struct Foo;

impl Rem for Foo {
    type Output = Foo;

    fn rem(self, _rhs: Foo) -> Foo {
        println!("Remainder-ing!");
        self
    }
}

fn main() {
    Foo % Foo;
}

Associated Types

type Output

Required Methods

fn rem(self, rhs: RHS) -> <Self as Rem<RHS>>::Output

The method for the % operator

Implementors