#[lang = "shr"]

pub trait Shr<RHS = Self> {
type Output;
#[must_use]

fn shr(self, rhs: RHS) -> Self::Output;
}

The right shift operator `>>`

. Note that because this trait is implemented
for all integer types with multiple right-hand-side types, Rust's type
checker has special handling for `_ >> _`

, setting the result type for
integer operations to the type of the left-hand-side operand. This means
that though `a >> b`

and `a.shr(b)`

are one and the same from an evaluation
standpoint, they are different when it comes to type inference.

An implementation of `Shr`

that lifts the `>>`

operation on integers to a
wrapper around `usize`

.

use std::ops::Shr;
#[derive(PartialEq, Debug)]
struct Scalar(usize);
impl Shr<Scalar> for Scalar {
type Output = Self;
fn shr(self, Scalar(rhs): Self) -> Scalar {
let Scalar(lhs) = self;
Scalar(lhs >> rhs)
}
}
assert_eq!(Scalar(16) >> Scalar(2), Scalar(4));Run

An implementation of `Shr`

that spins a vector rightward by a given amount.

use std::ops::Shr;
#[derive(PartialEq, Debug)]
struct SpinVector<T: Clone> {
vec: Vec<T>,
}
impl<T: Clone> Shr<usize> for SpinVector<T> {
type Output = Self;
fn shr(self, rhs: usize) -> SpinVector<T> {
let (a, b) = self.vec.split_at(self.vec.len() - rhs);
let mut spun_vector: Vec<T> = vec![];
spun_vector.extend_from_slice(b);
spun_vector.extend_from_slice(a);
SpinVector { vec: spun_vector }
}
}
assert_eq!(SpinVector { vec: vec![0, 1, 2, 3, 4] } >> 2,
SpinVector { vec: vec![3, 4, 0, 1, 2] });Run

The resulting type after applying the `>>`

operator.

Loading content...
#[must_use]

fn shr(self, rhs: RHS) -> Self::Output

Performs the `>>`

operation.

Loading content...
`impl<'a> Shr<&'a i128> for i8`

[src]

`impl<'a> Shr<&'a i128> for u8`

[src]

`impl<'a> Shr<&'a i16> for i16`

[src]

`impl<'a> Shr<&'a i16> for i32`

[src]

`impl<'a> Shr<&'a i16> for i64`

[src]

`impl<'a> Shr<&'a i16> for i8`

[src]

`impl<'a> Shr<&'a i16> for u16`

[src]

`impl<'a> Shr<&'a i16> for u32`

[src]

`impl<'a> Shr<&'a i16> for u64`

[src]

`impl<'a> Shr<&'a i16> for u8`

[src]

`impl<'a> Shr<&'a i32> for i16`

[src]

`impl<'a> Shr<&'a i32> for i32`

[src]

`impl<'a> Shr<&'a i32> for i64`

[src]

`impl<'a> Shr<&'a i32> for i8`

[src]

`impl<'a> Shr<&'a i32> for u16`

[src]

`impl<'a> Shr<&'a i32> for u32`

[src]

`impl<'a> Shr<&'a i32> for u64`

[src]

`impl<'a> Shr<&'a i32> for u8`

[src]

`impl<'a> Shr<&'a i64> for i16`

[src]

`impl<'a> Shr<&'a i64> for i32`

[src]

`impl<'a> Shr<&'a i64> for i64`

[src]

`impl<'a> Shr<&'a i64> for i8`

[src]

`impl<'a> Shr<&'a i64> for u16`

[src]

`impl<'a> Shr<&'a i64> for u32`

[src]

`impl<'a> Shr<&'a i64> for u64`

[src]

`impl<'a> Shr<&'a i64> for u8`

[src]

`impl<'a> Shr<&'a i8> for i128`

[src]

`impl<'a> Shr<&'a i8> for i16`

[src]

`impl<'a> Shr<&'a i8> for i32`

[src]

`impl<'a> Shr<&'a i8> for i64`

[src]

`impl<'a> Shr<&'a i8> for i8`

[src]

`impl<'a> Shr<&'a i8> for u128`

[src]

`impl<'a> Shr<&'a i8> for u16`

[src]

`impl<'a> Shr<&'a i8> for u32`

[src]

`impl<'a> Shr<&'a i8> for u64`

[src]

`impl<'a> Shr<&'a i8> for u8`

[src]

`impl<'a> Shr<&'a u128> for i8`

[src]

`impl<'a> Shr<&'a u128> for u8`

[src]

`impl<'a> Shr<&'a u16> for i16`

[src]

`impl<'a> Shr<&'a u16> for i32`

[src]

`impl<'a> Shr<&'a u16> for i64`

[src]

`impl<'a> Shr<&'a u16> for i8`

[src]

`impl<'a> Shr<&'a u16> for u16`

[src]

`impl<'a> Shr<&'a u16> for u32`

[src]

`impl<'a> Shr<&'a u16> for u64`

[src]

`impl<'a> Shr<&'a u16> for u8`

[src]

`impl<'a> Shr<&'a u32> for i16`

[src]

`impl<'a> Shr<&'a u32> for i32`

[src]

`impl<'a> Shr<&'a u32> for i64`

[src]

`impl<'a> Shr<&'a u32> for i8`

[src]

`impl<'a> Shr<&'a u32> for u16`

[src]

`impl<'a> Shr<&'a u32> for u32`

[src]

`impl<'a> Shr<&'a u32> for u64`

[src]

`impl<'a> Shr<&'a u32> for u8`

[src]

`impl<'a> Shr<&'a u64> for i16`

[src]

`impl<'a> Shr<&'a u64> for i32`

[src]

`impl<'a> Shr<&'a u64> for i64`

[src]

`impl<'a> Shr<&'a u64> for i8`

[src]

`impl<'a> Shr<&'a u64> for u16`

[src]

`impl<'a> Shr<&'a u64> for u32`

[src]

`impl<'a> Shr<&'a u64> for u64`

[src]

`impl<'a> Shr<&'a u64> for u8`

[src]

`impl<'a> Shr<&'a u8> for i128`

[src]

`impl<'a> Shr<&'a u8> for i16`

[src]

`impl<'a> Shr<&'a u8> for i32`

[src]

`impl<'a> Shr<&'a u8> for i64`

[src]

`impl<'a> Shr<&'a u8> for i8`

[src]

`impl<'a> Shr<&'a u8> for u128`

[src]

`impl<'a> Shr<&'a u8> for u16`

[src]

`impl<'a> Shr<&'a u8> for u32`

[src]

`impl<'a> Shr<&'a u8> for u64`

[src]

`impl<'a> Shr<&'a u8> for u8`

[src]

`impl<'a> Shr<i128> for &'a i8`

[src]

`impl<'a> Shr<i128> for &'a u8`

[src]

`impl<'a> Shr<i16> for &'a i16`

[src]

`impl<'a> Shr<i16> for &'a i32`

[src]

`impl<'a> Shr<i16> for &'a i64`

[src]

`impl<'a> Shr<i16> for &'a i8`

[src]

`impl<'a> Shr<i16> for &'a u16`

[src]

`impl<'a> Shr<i16> for &'a u32`

[src]

`impl<'a> Shr<i16> for &'a u64`

[src]

`impl<'a> Shr<i16> for &'a u8`

[src]

`impl<'a> Shr<i32> for &'a i16`

[src]

`impl<'a> Shr<i32> for &'a i32`

[src]

`impl<'a> Shr<i32> for &'a i64`

[src]

`impl<'a> Shr<i32> for &'a i8`

[src]

`impl<'a> Shr<i32> for &'a u16`

[src]

`impl<'a> Shr<i32> for &'a u32`

[src]

`impl<'a> Shr<i32> for &'a u64`

[src]

`impl<'a> Shr<i32> for &'a u8`

[src]

`impl<'a> Shr<i64> for &'a i16`

[src]

`impl<'a> Shr<i64> for &'a i32`

[src]

`impl<'a> Shr<i64> for &'a i64`

[src]

`impl<'a> Shr<i64> for &'a i8`

[src]

`impl<'a> Shr<i64> for &'a u16`

[src]

`impl<'a> Shr<i64> for &'a u32`

[src]

`impl<'a> Shr<i64> for &'a u64`

[src]

`impl<'a> Shr<i64> for &'a u8`

[src]

`impl<'a> Shr<i8> for &'a i128`

[src]

`impl<'a> Shr<i8> for &'a i16`

[src]

`impl<'a> Shr<i8> for &'a i32`

[src]

`impl<'a> Shr<i8> for &'a i64`

[src]

`impl<'a> Shr<i8> for &'a i8`

[src]

`impl<'a> Shr<i8> for &'a u128`

[src]

`impl<'a> Shr<i8> for &'a u16`

[src]

`impl<'a> Shr<i8> for &'a u32`

[src]

`impl<'a> Shr<i8> for &'a u64`

[src]

`impl<'a> Shr<i8> for &'a u8`

[src]

`impl<'a> Shr<u128> for &'a i8`

[src]

`impl<'a> Shr<u128> for &'a u8`

[src]

`impl<'a> Shr<u16> for &'a i16`

[src]

`impl<'a> Shr<u16> for &'a i32`

[src]

`impl<'a> Shr<u16> for &'a i64`

[src]

`impl<'a> Shr<u16> for &'a i8`

[src]

`impl<'a> Shr<u16> for &'a u16`

[src]

`impl<'a> Shr<u16> for &'a u32`

[src]

`impl<'a> Shr<u16> for &'a u64`

[src]

`impl<'a> Shr<u16> for &'a u8`

[src]

`impl<'a> Shr<u32> for &'a i16`

[src]

`impl<'a> Shr<u32> for &'a i32`

[src]

`impl<'a> Shr<u32> for &'a i64`

[src]

`impl<'a> Shr<u32> for &'a i8`

[src]

`impl<'a> Shr<u32> for &'a u16`

[src]

`impl<'a> Shr<u32> for &'a u32`

[src]

`impl<'a> Shr<u32> for &'a u64`

[src]

`impl<'a> Shr<u32> for &'a u8`

[src]

`impl<'a> Shr<u64> for &'a i16`

[src]

`impl<'a> Shr<u64> for &'a i32`

[src]

`impl<'a> Shr<u64> for &'a i64`

[src]

`impl<'a> Shr<u64> for &'a i8`

[src]

`impl<'a> Shr<u64> for &'a u16`

[src]

`impl<'a> Shr<u64> for &'a u32`

[src]

`impl<'a> Shr<u64> for &'a u64`

[src]

`impl<'a> Shr<u64> for &'a u8`

[src]

`impl<'a> Shr<u8> for &'a i128`

[src]

`impl<'a> Shr<u8> for &'a i16`

[src]

`impl<'a> Shr<u8> for &'a i32`

[src]

`impl<'a> Shr<u8> for &'a i64`

[src]

`impl<'a> Shr<u8> for &'a i8`

[src]

`impl<'a> Shr<u8> for &'a u128`

[src]

`impl<'a> Shr<u8> for &'a u16`

[src]

`impl<'a> Shr<u8> for &'a u32`

[src]

`impl<'a> Shr<u8> for &'a u64`

[src]

`impl<'a> Shr<u8> for &'a u8`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a i128> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a i16> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a i32> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a i64> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a i8> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a isize> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a u128> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a u16> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a u32> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a u64> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b usize`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a u8> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b i128`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b i16`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b i32`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b i64`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b i8`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b isize`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b u128`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b u16`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b u32`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b u64`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b u8`

[src]

`impl<'a, 'b> Shr<&'a usize> for &'b usize`

[src]

Loading content...