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§

source

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);

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl WrappingShl for i8

source§

fn wrapping_shl(&self, rhs: u32) -> i8

source§

impl WrappingShl for i16

source§

fn wrapping_shl(&self, rhs: u32) -> i16

source§

impl WrappingShl for i32

source§

fn wrapping_shl(&self, rhs: u32) -> i32

source§

impl WrappingShl for i64

source§

fn wrapping_shl(&self, rhs: u32) -> i64

source§

impl WrappingShl for i128

source§

fn wrapping_shl(&self, rhs: u32) -> i128

source§

impl WrappingShl for isize

source§

fn wrapping_shl(&self, rhs: u32) -> isize

source§

impl WrappingShl for u8

source§

fn wrapping_shl(&self, rhs: u32) -> u8

source§

impl WrappingShl for u16

source§

fn wrapping_shl(&self, rhs: u32) -> u16

source§

impl WrappingShl for u32

source§

fn wrapping_shl(&self, rhs: u32) -> u32

source§

impl WrappingShl for u64

source§

fn wrapping_shl(&self, rhs: u32) -> u64

source§

impl WrappingShl for u128

source§

fn wrapping_shl(&self, rhs: u32) -> u128

source§

impl WrappingShl for usize

source§

fn wrapping_shl(&self, rhs: u32) -> usize

source§

impl<T> WrappingShl for Wrapping<T>
where T: WrappingShl, Wrapping<T>: Shl<usize, Output = Wrapping<T>>,

source§

fn wrapping_shl(&self, rhs: u32) -> Wrapping<T>

Implementors§