W3cubDocs

/Rust

Trait std::ops::ShrAssign

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

The right shift assignment operator >>=.

Examples

An implementation of ShrAssign for a wrapper around usize.

use std::ops::ShrAssign;

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

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

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

Required Methods

Performs the >>= operation.

Implementors

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/ops/trait.ShrAssign.html