Trait std::ops::ShlAssign1.8.0 [] [src]

#[lang = "shl_assign"]
pub trait ShlAssign<Rhs> { fn shl_assign(&mut self, rhs: Rhs); }

The left shift assignment operator <<=.

Examples

An implementation of ShlAssign for a wrapper around usize.

use std::ops::ShlAssign;

#[derive(Debug, PartialEq)]
struct Scalar(usize);

impl ShlAssign<usize> for Scalar {
    fn shl_assign(&mut self, rhs: usize) {
        self.0 <<= rhs;
    }
}

let mut scalar = Scalar(4);
scalar <<= 2;
assert_eq!(scalar, Scalar(16));Run

Required Methods

Performs the <<= operation.

Implementors