Trait std::ops::Mul [] [src]

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

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

Examples

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

use std::ops::Mul;

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