Trait scale_info::prelude::ops::ShrAssign
1.8.0 · source · pub trait ShrAssign<Rhs = Self> {
// Required method
fn shr_assign(&mut self, rhs: Rhs);
}
Expand description
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§
sourcefn shr_assign(&mut self, rhs: Rhs)
fn shr_assign(&mut self, rhs: Rhs)
Performs the >>=
operation.
Examples
let mut x: u8 = 5;
x >>= 1;
assert_eq!(x, 2);
let mut x: u8 = 2;
x >>= 1;
assert_eq!(x, 1);