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

pub struct BitPat { /* fields omitted */ }

A 128-bit pattern.


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.


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.

Trait Implementations

impl Clone for BitPat[src]

impl Copy for BitPat[src]

impl Default for BitPat[src]

impl Eq for BitPat[src]

impl PartialEq<BitPat> for BitPat[src]

impl Display for BitPat[src]

impl Debug for BitPat[src]

impl Hash for BitPat[src]

impl StructuralPartialEq for BitPat[src]

impl StructuralEq for BitPat[src]

Auto Trait Implementations

impl Send for BitPat

impl Sync for BitPat

impl Unpin for BitPat

impl UnwindSafe for BitPat

impl RefUnwindSafe for BitPat

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 

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

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

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