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

pub trait Sub<RHS, Result> {
    fn sub(self, rhs: RHS) -> Result;
}

The Sub trait is used to specify the functionality of -.

Example

A trivial implementation of Sub. When Foo - Foo happens, it ends up calling sub, and therefore, main prints Subtracting!.

#[deriving(Copy)] struct Foo; impl Sub<Foo, Foo> for Foo { fn sub(self, _rhs: Foo) -> Foo { println!("Subtracting!"); self } } fn main() { Foo - Foo; }
#[deriving(Copy)]
struct Foo;

impl Sub<Foo, Foo> for Foo {
    fn sub(self, _rhs: Foo) -> Foo {
        println!("Subtracting!");
        self
    }
}

fn main() {
    Foo - Foo;
}

Required Methods

fn sub(self, rhs: RHS) -> Result

The method for the - operator

Implementors