pub trait WrappingShl: Sized + Shl<usize, Output = Self> {
    fn wrapping_shl(&self, rhs: u32) -> Self;
}
Expand description

Performs a left shift that does not panic.

Required Methods§

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

Implementations on Foreign Types§

Implementors§

impl<Frac> WrappingShl for FixedI8<Frac>

impl<Frac> WrappingShl for FixedI16<Frac>

impl<Frac> WrappingShl for FixedI32<Frac>

impl<Frac> WrappingShl for FixedI64<Frac>

impl<Frac> WrappingShl for FixedI128<Frac>

impl<Frac> WrappingShl for FixedU8<Frac>

impl<Frac> WrappingShl for FixedU16<Frac>

impl<Frac> WrappingShl for FixedU32<Frac>

impl<Frac> WrappingShl for FixedU64<Frac>

impl<Frac> WrappingShl for FixedU128<Frac>