num_traits::ops::wrapping

Trait WrappingShr

Source
pub trait WrappingShr: Sized + Shr<usize, Output = Self> {
    // Required method
    fn wrapping_shr(&self, rhs: u32) -> Self;
}
Expand description

Performs a right shift that does not panic.

Required Methods§

Source

fn wrapping_shr(&self, rhs: u32) -> Self

Panic-free bitwise shift-right; 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::WrappingShr;

let x: u16 = 0x8000;

assert_eq!(WrappingShr::wrapping_shr(&x, 0),  0x8000);
assert_eq!(WrappingShr::wrapping_shr(&x, 1),  0x4000);
assert_eq!(WrappingShr::wrapping_shr(&x, 15), 0x0001);
assert_eq!(WrappingShr::wrapping_shr(&x, 16), 0x8000);

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 WrappingShr for i8

Source§

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

Source§

impl WrappingShr for i16

Source§

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

Source§

impl WrappingShr for i32

Source§

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

Source§

impl WrappingShr for i64

Source§

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

Source§

impl WrappingShr for i128

Source§

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

Source§

impl WrappingShr for isize

Source§

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

Source§

impl WrappingShr for u8

Source§

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

Source§

impl WrappingShr for u16

Source§

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

Source§

impl WrappingShr for u32

Source§

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

Source§

impl WrappingShr for u64

Source§

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

Source§

impl WrappingShr for u128

Source§

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

Source§

impl WrappingShr for usize

Source§

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

Source§

impl<T: WrappingShr> WrappingShr for Wrapping<T>
where Wrapping<T>: Shr<usize, Output = Wrapping<T>>,

Source§

fn wrapping_shr(&self, rhs: u32) -> Self

Implementors§