Trait core::ops::Div [] [src]

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

The Div`Divtrait is used to specify the functionality of` trait is used to specify the functionality of /`/`.

Examples

A trivial implementation of Div`Div. When`. When Foo / Foo`Foo / Foohappens, it ends up calling` happens, it ends up calling div`div, and therefore,`, and therefore, main`mainprints` prints Dividing!`Dividing!`.

use std::ops::Div; #[derive(Copy, Clone)] struct Foo; impl Div for Foo { type Output = Foo; fn div(self, _rhs: Foo) -> Foo { println!("Dividing!"); self } } fn main() { Foo / Foo; }
use std::ops::Div;

#[derive(Copy, Clone)]
struct Foo;

impl Div for Foo {
    type Output = Foo;

    fn div(self, _rhs: Foo) -> Foo {
        println!("Dividing!");
        self
    }
}

fn main() {
    Foo / Foo;
}

Associated Types

type Output

The resulting type after applying the /`/` operator

Required Methods

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

The method for the /`/` operator

Implementors