#[lang = "shl"]
pub trait Shl<Rhs = Self> {
type Output;
#[must_use]
fn shl(self, rhs: Rhs) -> Self::Output;
}
The left 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.shl(b)
are one and the same from an evaluation
standpoint, they are different when it comes to type inference.
An implementation of Shl
that lifts the <<
operation on integers to a
wrapper around usize
.
use std::ops::Shl;
#[derive(PartialEq, Debug)]
struct Scalar(usize);
impl Shl<Scalar> for Scalar {
type Output = Self;
fn shl(self, Scalar(rhs): Self) -> Scalar {
let Scalar(lhs) = self;
Scalar(lhs << rhs)
}
}
assert_eq!(Scalar(4) << Scalar(2), Scalar(16));Run
An implementation of Shl
that spins a vector leftward by a given amount.
use std::ops::Shl;
#[derive(PartialEq, Debug)]
struct SpinVector<T: Clone> {
vec: Vec<T>,
}
impl<T: Clone> Shl<usize> for SpinVector<T> {
type Output = Self;
fn shl(self, rhs: usize) -> Self::Output {
let (a, b) = self.vec.split_at(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![2, 3, 4, 0, 1] });Run
The resulting type after applying the <<
operator.
Loading content...
#[must_use]
fn shl(self, rhs: Rhs) -> Self::Output
Performs the <<
operation.
Loading content...
impl<'_> Shl<&'_ i128> for i8
[src]
impl<'_> Shl<&'_ i128> for u8
[src]
impl<'_> Shl<&'_ i16> for i16
[src]
impl<'_> Shl<&'_ i16> for i32
[src]
impl<'_> Shl<&'_ i16> for i64
[src]
impl<'_> Shl<&'_ i16> for i8
[src]
impl<'_> Shl<&'_ i16> for u16
[src]
impl<'_> Shl<&'_ i16> for u32
[src]
impl<'_> Shl<&'_ i16> for u64
[src]
impl<'_> Shl<&'_ i16> for u8
[src]
impl<'_> Shl<&'_ i32> for i16
[src]
impl<'_> Shl<&'_ i32> for i32
[src]
impl<'_> Shl<&'_ i32> for i64
[src]
impl<'_> Shl<&'_ i32> for i8
[src]
impl<'_> Shl<&'_ i32> for u16
[src]
impl<'_> Shl<&'_ i32> for u32
[src]
impl<'_> Shl<&'_ i32> for u64
[src]
impl<'_> Shl<&'_ i32> for u8
[src]
impl<'_> Shl<&'_ i64> for i16
[src]
impl<'_> Shl<&'_ i64> for i32
[src]
impl<'_> Shl<&'_ i64> for i64
[src]
impl<'_> Shl<&'_ i64> for i8
[src]
impl<'_> Shl<&'_ i64> for u16
[src]
impl<'_> Shl<&'_ i64> for u32
[src]
impl<'_> Shl<&'_ i64> for u64
[src]
impl<'_> Shl<&'_ i64> for u8
[src]
impl<'_> Shl<&'_ i8> for i128
[src]
impl<'_> Shl<&'_ i8> for i16
[src]
impl<'_> Shl<&'_ i8> for i32
[src]
impl<'_> Shl<&'_ i8> for i64
[src]
impl<'_> Shl<&'_ i8> for i8
[src]
impl<'_> Shl<&'_ i8> for u128
[src]
impl<'_> Shl<&'_ i8> for u16
[src]
impl<'_> Shl<&'_ i8> for u32
[src]
impl<'_> Shl<&'_ i8> for u64
[src]
impl<'_> Shl<&'_ i8> for u8
[src]
impl<'_> Shl<&'_ u128> for i8
[src]
impl<'_> Shl<&'_ u128> for u8
[src]
impl<'_> Shl<&'_ u16> for i16
[src]
impl<'_> Shl<&'_ u16> for i32
[src]
impl<'_> Shl<&'_ u16> for i64
[src]
impl<'_> Shl<&'_ u16> for i8
[src]
impl<'_> Shl<&'_ u16> for u16
[src]
impl<'_> Shl<&'_ u16> for u32
[src]
impl<'_> Shl<&'_ u16> for u64
[src]
impl<'_> Shl<&'_ u16> for u8
[src]
impl<'_> Shl<&'_ u32> for i16
[src]
impl<'_> Shl<&'_ u32> for i32
[src]
impl<'_> Shl<&'_ u32> for i64
[src]
impl<'_> Shl<&'_ u32> for i8
[src]
impl<'_> Shl<&'_ u32> for u16
[src]
impl<'_> Shl<&'_ u32> for u32
[src]
impl<'_> Shl<&'_ u32> for u64
[src]
impl<'_> Shl<&'_ u32> for u8
[src]
impl<'_> Shl<&'_ u64> for i16
[src]
impl<'_> Shl<&'_ u64> for i32
[src]
impl<'_> Shl<&'_ u64> for i64
[src]
impl<'_> Shl<&'_ u64> for i8
[src]
impl<'_> Shl<&'_ u64> for u16
[src]
impl<'_> Shl<&'_ u64> for u32
[src]
impl<'_> Shl<&'_ u64> for u64
[src]
impl<'_> Shl<&'_ u64> for u8
[src]
impl<'_> Shl<&'_ u8> for i128
[src]
impl<'_> Shl<&'_ u8> for i16
[src]
impl<'_> Shl<&'_ u8> for i32
[src]
impl<'_> Shl<&'_ u8> for i64
[src]
impl<'_> Shl<&'_ u8> for i8
[src]
impl<'_> Shl<&'_ u8> for u128
[src]
impl<'_> Shl<&'_ u8> for u16
[src]
impl<'_> Shl<&'_ u8> for u32
[src]
impl<'_> Shl<&'_ u8> for u64
[src]
impl<'_> Shl<&'_ u8> for u8
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ i128> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ i16> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ i32> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ i64> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ i8> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ isize> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ u128> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ u16> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ u32> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ u64> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ usize
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ u8> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ i128
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ i16
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ i32
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ i64
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ i8
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ isize
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ u128
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ u16
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ u32
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ u64
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ u8
[src]
impl<'_, '_> Shl<&'_ usize> for &'_ usize
[src]
impl<'a> Shl<i128> for &'a i8
[src]
impl<'a> Shl<i128> for &'a u8
[src]
impl<'a> Shl<i16> for &'a i16
[src]
impl<'a> Shl<i16> for &'a i32
[src]
impl<'a> Shl<i16> for &'a i64
[src]
impl<'a> Shl<i16> for &'a i8
[src]
impl<'a> Shl<i16> for &'a u16
[src]
impl<'a> Shl<i16> for &'a u32
[src]
impl<'a> Shl<i16> for &'a u64
[src]
impl<'a> Shl<i16> for &'a u8
[src]
impl<'a> Shl<i32> for &'a i16
[src]
impl<'a> Shl<i32> for &'a i32
[src]
impl<'a> Shl<i32> for &'a i64
[src]
impl<'a> Shl<i32> for &'a i8
[src]
impl<'a> Shl<i32> for &'a u16
[src]
impl<'a> Shl<i32> for &'a u32
[src]
impl<'a> Shl<i32> for &'a u64
[src]
impl<'a> Shl<i32> for &'a u8
[src]
impl<'a> Shl<i64> for &'a i16
[src]
impl<'a> Shl<i64> for &'a i32
[src]
impl<'a> Shl<i64> for &'a i64
[src]
impl<'a> Shl<i64> for &'a i8
[src]
impl<'a> Shl<i64> for &'a u16
[src]
impl<'a> Shl<i64> for &'a u32
[src]
impl<'a> Shl<i64> for &'a u64
[src]
impl<'a> Shl<i64> for &'a u8
[src]
impl<'a> Shl<i8> for &'a i128
[src]
impl<'a> Shl<i8> for &'a i16
[src]
impl<'a> Shl<i8> for &'a i32
[src]
impl<'a> Shl<i8> for &'a i64
[src]
impl<'a> Shl<i8> for &'a i8
[src]
impl<'a> Shl<i8> for &'a u128
[src]
impl<'a> Shl<i8> for &'a u16
[src]
impl<'a> Shl<i8> for &'a u32
[src]
impl<'a> Shl<i8> for &'a u64
[src]
impl<'a> Shl<i8> for &'a u8
[src]
impl<'a> Shl<u128> for &'a i8
[src]
impl<'a> Shl<u128> for &'a u8
[src]
impl<'a> Shl<u16> for &'a i16
[src]
impl<'a> Shl<u16> for &'a i32
[src]
impl<'a> Shl<u16> for &'a i64
[src]
impl<'a> Shl<u16> for &'a i8
[src]
impl<'a> Shl<u16> for &'a u16
[src]
impl<'a> Shl<u16> for &'a u32
[src]
impl<'a> Shl<u16> for &'a u64
[src]
impl<'a> Shl<u16> for &'a u8
[src]
impl<'a> Shl<u32> for &'a i16
[src]
impl<'a> Shl<u32> for &'a i32
[src]
impl<'a> Shl<u32> for &'a i64
[src]
impl<'a> Shl<u32> for &'a i8
[src]
impl<'a> Shl<u32> for &'a u16
[src]
impl<'a> Shl<u32> for &'a u32
[src]
impl<'a> Shl<u32> for &'a u64
[src]
impl<'a> Shl<u32> for &'a u8
[src]
impl<'a> Shl<u64> for &'a i16
[src]
impl<'a> Shl<u64> for &'a i32
[src]
impl<'a> Shl<u64> for &'a i64
[src]
impl<'a> Shl<u64> for &'a i8
[src]
impl<'a> Shl<u64> for &'a u16
[src]
impl<'a> Shl<u64> for &'a u32
[src]
impl<'a> Shl<u64> for &'a u64
[src]
impl<'a> Shl<u64> for &'a u8
[src]
impl<'a> Shl<u8> for &'a i128
[src]
impl<'a> Shl<u8> for &'a i16
[src]
impl<'a> Shl<u8> for &'a i32
[src]
impl<'a> Shl<u8> for &'a i64
[src]
impl<'a> Shl<u8> for &'a i8
[src]
impl<'a> Shl<u8> for &'a u128
[src]
impl<'a> Shl<u8> for &'a u16
[src]
impl<'a> Shl<u8> for &'a u32
[src]
impl<'a> Shl<u8> for &'a u64
[src]
impl<'a> Shl<u8> for &'a u8
[src]
Loading content...