Trait core::ops::DivStable [-]  [+] [src]

pub trait Div<RHS = Self> {
    type Output;

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

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

Example

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

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

use std::ops::Div;

#[derive(Copy)]
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

Required Methods

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

The method for the / operator

Implementors