Skip to main content

ExtractBits

Trait ExtractBits 

Source
pub trait ExtractBits: Sized {
    type Output;

    // Required method
    fn extract_bits(self, mask: Self) -> Self::Output;
}
Expand description

Gathers bits through a mask (the PEXT operation).

Required Associated Types§

Source

type Output

Gathers the bits of self selected by the one-bits of mask into the contiguous low-order bits of the result (the PEXT operation). Like std, this is only provided for unsigned types.

use const_num_traits::ExtractBits;

assert_eq!(ExtractBits::extract_bits(0b0101_0011u8, 0b1111_0000), 0b101);

Required Methods§

Source

fn extract_bits(self, mask: Self) -> Self::Output

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ExtractBits for u8

Source§

type Output = u8

Source§

fn extract_bits(self, mask: Self) -> Self

Source§

impl ExtractBits for u16

Source§

type Output = u16

Source§

fn extract_bits(self, mask: Self) -> Self

Source§

impl ExtractBits for u32

Source§

type Output = u32

Source§

fn extract_bits(self, mask: Self) -> Self

Source§

impl ExtractBits for u64

Source§

type Output = u64

Source§

fn extract_bits(self, mask: Self) -> Self

Source§

impl ExtractBits for u128

Source§

type Output = u128

Source§

fn extract_bits(self, mask: Self) -> Self

Source§

impl ExtractBits for usize

Source§

type Output = usize

Source§

fn extract_bits(self, mask: Self) -> Self

Implementors§