pub trait WrappingShl: Sized + Shl<usize, Output = Self> {
// Required method
fn wrapping_shl(&self, rhs: u32) -> Self;
}
Expand description
Performs a left shift that does not panic.
Required Methods§
Sourcefn wrapping_shl(&self, rhs: u32) -> Self
fn wrapping_shl(&self, rhs: u32) -> Self
Panic-free bitwise shift-left; yields self << mask(rhs)
,
where mask
removes any high order bits of rhs
that would
cause the shift to exceed the bitwidth of the type.
use num_traits::WrappingShl;
let x: u16 = 0x0001;
assert_eq!(WrappingShl::wrapping_shl(&x, 0), 0x0001);
assert_eq!(WrappingShl::wrapping_shl(&x, 1), 0x0002);
assert_eq!(WrappingShl::wrapping_shl(&x, 15), 0x8000);
assert_eq!(WrappingShl::wrapping_shl(&x, 16), 0x0001);
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl WrappingShl for i8
impl WrappingShl for i8
fn wrapping_shl(&self, rhs: u32) -> i8
Source§impl WrappingShl for i16
impl WrappingShl for i16
fn wrapping_shl(&self, rhs: u32) -> i16
Source§impl WrappingShl for i32
impl WrappingShl for i32
fn wrapping_shl(&self, rhs: u32) -> i32
Source§impl WrappingShl for i64
impl WrappingShl for i64
fn wrapping_shl(&self, rhs: u32) -> i64
Source§impl WrappingShl for i128
impl WrappingShl for i128
fn wrapping_shl(&self, rhs: u32) -> i128
Source§impl WrappingShl for isize
impl WrappingShl for isize
fn wrapping_shl(&self, rhs: u32) -> isize
Source§impl WrappingShl for u8
impl WrappingShl for u8
fn wrapping_shl(&self, rhs: u32) -> u8
Source§impl WrappingShl for u16
impl WrappingShl for u16
fn wrapping_shl(&self, rhs: u32) -> u16
Source§impl WrappingShl for u32
impl WrappingShl for u32
fn wrapping_shl(&self, rhs: u32) -> u32
Source§impl WrappingShl for u64
impl WrappingShl for u64
fn wrapping_shl(&self, rhs: u32) -> u64
Source§impl WrappingShl for u128
impl WrappingShl for u128
fn wrapping_shl(&self, rhs: u32) -> u128
Source§impl WrappingShl for usize
impl WrappingShl for usize
fn wrapping_shl(&self, rhs: u32) -> usize
Source§impl<T> WrappingShl for Wrapping<T>
impl<T> WrappingShl for Wrapping<T>
fn wrapping_shl(&self, rhs: u32) -> Wrapping<T>
Implementors§
impl WrappingShl for BoxedUint
Available on crate feature
alloc
only.