Trait std::ops::Rem [] [src]

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

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

Examples

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

use std::ops::Rem; 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;

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 = Self

The resulting type after applying the % operator

Required Methods

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

The method for the % operator

Implementors