referrerpolicy=no-referrer-when-downgrade

Trait frame_support::pallet_prelude::CheckedShr

source ·
pub trait CheckedShr: Sized + Shr<u32, Output = Self> {
    // Required method
    fn checked_shr(&self, rhs: u32) -> Option<Self>;
}
Expand description

Performs a right shift that returns None on shifts larger than or equal to the type width.

Required Methods§

source

fn checked_shr(&self, rhs: u32) -> Option<Self>

Checked shift right. Computes self >> rhs, returning None if rhs is larger than or equal to the number of bits in self.

use num_traits::CheckedShr;

let x: u16 = 0x8000;

assert_eq!(CheckedShr::checked_shr(&x, 0),  Some(0x8000));
assert_eq!(CheckedShr::checked_shr(&x, 1),  Some(0x4000));
assert_eq!(CheckedShr::checked_shr(&x, 15), Some(0x0001));
assert_eq!(CheckedShr::checked_shr(&x, 16), None);

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl CheckedShr for i8

source§

fn checked_shr(&self, rhs: u32) -> Option<i8>

source§

impl CheckedShr for i16

source§

fn checked_shr(&self, rhs: u32) -> Option<i16>

source§

impl CheckedShr for i32

source§

fn checked_shr(&self, rhs: u32) -> Option<i32>

source§

impl CheckedShr for i64

source§

fn checked_shr(&self, rhs: u32) -> Option<i64>

source§

impl CheckedShr for i128

source§

fn checked_shr(&self, rhs: u32) -> Option<i128>

source§

impl CheckedShr for isize

source§

fn checked_shr(&self, rhs: u32) -> Option<isize>

source§

impl CheckedShr for u8

source§

fn checked_shr(&self, rhs: u32) -> Option<u8>

source§

impl CheckedShr for u16

source§

fn checked_shr(&self, rhs: u32) -> Option<u16>

source§

impl CheckedShr for u32

source§

fn checked_shr(&self, rhs: u32) -> Option<u32>

source§

impl CheckedShr for u64

source§

fn checked_shr(&self, rhs: u32) -> Option<u64>

source§

impl CheckedShr for u128

source§

fn checked_shr(&self, rhs: u32) -> Option<u128>

source§

impl CheckedShr for usize

source§

fn checked_shr(&self, rhs: u32) -> Option<usize>

source§

impl<T, D> CheckedShr for TypeWithDefault<T, D>
where T: CheckedShr, D: Get<T>,

Implementors§