[][src]Struct gf::support::bitpat::BitPat

pub struct BitPat { /* fields omitted */ }

A 128-bit pattern.

Implementations

impl BitPat[src]

pub fn new(bits: u128, mask: u128) -> Self[src]

Create a new bit pattern from bits and mask.

pub fn bits(&self) -> u128[src]

Return pattern bits, with masked out bits normalized to 0.

pub fn mask(&self) -> u128[src]

Return pattern mask.

pub fn is_empty(&self) -> bool[src]

Return true iff this pattern has a zero mask and therefore accepts any input.

pub fn len(&self) -> usize[src]

Return pattern length, based on position of most significant set bit in the mask.

pub fn restrict_mask(&mut self, mask: u128)[src]

Restrict pattern mask; the resulting mask is the logical AND between the current mask and the mask argument.

pub fn accepts(&self, bits: u128) -> bool[src]

Check if this pattern accepts bits as a match from the start.

pub fn gather(&self) -> u128[src]

Gather the bits selected by the mask into lower bits of the result and set the remaining upper bits to zero.

On x86-64 processors supporting BMI2, this is implemented through the PEXT instruction.

Example

assert_eq!(BitPat::new(0x1234_5678, 0xFF00_FFF0).gather(), 0x0001_2567);

pub fn gather_bit_vec(&self) -> BitVec[src]

Gather the bits selected by the mask into a bit vector. The bit vector length is the number of set bits in mask.

pub fn scatter(value: u128, mask: u128) -> Self[src]

Scatter the lower bits of value using mask and set the remaining bits to zero.

On x86-64 processors supporting BMI2, this is implemented through the PDEP instruction.

Example

assert_eq!(BitPat::scatter(0x0001_2567, 0xFF00_FFF0), BitPat::new(0x1200_5670, 0xFF00_FFF0));

Trait Implementations

impl Clone for BitPat[src]

impl Copy for BitPat[src]

impl Debug for BitPat[src]

impl Default for BitPat[src]

impl Display for BitPat[src]

impl Eq for BitPat[src]

impl Hash for BitPat[src]

impl PartialEq<BitPat> for BitPat[src]

impl StructuralEq for BitPat[src]

impl StructuralPartialEq for BitPat[src]

Auto Trait Implementations

impl RefUnwindSafe for BitPat

impl Send for BitPat

impl Sync for BitPat

impl Unpin for BitPat

impl UnwindSafe for BitPat

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.