Trait std::ops::Div [] [src]

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

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

Examples

A trivial implementation of Div. When Foo / Foo happens, it ends up calling div, and therefore, main prints 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