MulAssign in std::ops - Rust (original) (raw)

logo

pub trait MulAssign<Rhs = Self> {
    fn mul_assign(&mut self, rhs: Rhs);
}

Expand description

The multiplication assignment operator *=.

Examples

use std::ops::MulAssign;

#[derive(Debug, PartialEq)]
struct Frequency { hertz: f64 }

impl MulAssign<f64> for Frequency {
    fn mul_assign(&mut self, rhs: f64) {
        self.hertz *= rhs;
    }
}

let mut frequency = Frequency { hertz: 50.0 };
frequency *= 4.0;
assert_eq!(Frequency { hertz: 200.0 }, frequency);

Run

Required methods

fn mul_assign(&mut self, rhs: Rhs)

Performs the *= operation.

Example
let mut x: u32 = 12;
x *= 2;
assert_eq!(x, 24);

Run

Implementors

impl<T, U, const LANES: usize> MulAssign for Simd<T, LANES> where

T: SimdElement,
Simd<T, LANES>: Mul,
LaneCount: SupportedLaneCount,
<Simd<T, LANES> as Mul>::Output == Simd<T, LANES>,