[−][src]Struct gf::support::bitpat::BitPat
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]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,