Trait core::ops::Mul [] [src]

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

The Mul`Multrait is used to specify the functionality of` trait is used to specify the functionality of *`*`.

Examples

A trivial implementation of Mul`Mul. When`. When Foo * Foo`Foo * Foohappens, it ends up calling` happens, it ends up calling mul`mul, and therefore,`, and therefore, main`mainprints` prints Multiplying!`Multiplying!`.

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

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

impl Mul for Foo {
    type Output = Foo;

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

fn main() {
    Foo * Foo;
}

Associated Types

type Output

The resulting type after applying the *`*` operator

Required Methods

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

The method for the *`*` operator

Implementors