pub trait Multiplicative:
Object
+ for<'a> MulAssign<&'a Self>
+ for<'a> Mul<&'a Self, Output = Self> {
// Provided method
fn square(&mut self) { ... }
}Expand description
A type that supports multiplication.
For some type T implementing this trait, the following operations must be
supported:
&mut T *= &T,T * &T.
As with Additive, the borrowing scheme is chosen to keep implementations
efficient even for heavier structures.
§Usage
// We use .clone() whenever ownership is needed.
fn example<T: Multiplicative>(mut x: T, y: T) {
x *= &y;
x.clone() * &y;
}Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.