Struct BitSubset64

Source
pub struct BitSubset64<T: Cast<u64> = u64>
where u64: Cast<T>,
{ pub tag: u64, pub mask: u64, /* private fields */ }
Expand description

A bit subset of u64.

This structure represents a subset of bits within a 64-bit unsigned integer, defined by a specific pattern where each bit is either 0, 1, or S.

  • 0 means the bit is always 0. These bits contribute to both the tag and the mask.
  • 1 means the bit is always 1. These bits also contribute to both the tag and the mask.
  • S represents a superposition state, meaning the bit can be either 0 or 1.

The cardinality of the set is calculated as 2^(superposition.count_ones()), representing the number of unique combinations possible within the superposition bits.

The following table summarizes how each field is derived:

Property01SDescription
union011items.reduce(or)
tag010items.reduce(and)
superposition001union ^ tag
mask110!superposition

Fields§

§tag: u64

Represents the intersection of all items in the subset. A pattern of bits where a 1 in each position indicates that the corresponding bit is consistently 1 across all items, and a 0 indicates that it is not consistently 1.

§mask: u64

Identifies the bits that are constant (either 0 or 1). A 1 in a position indicates a fixed bit (as per the tag), and a 0 indicates a superposition bit.

Implementations§

Source§

impl BitSubset64<u64>

Source

pub const fn cast<U: Cast<u64>>(self) -> BitSubset64<U>
where u64: Cast<U>,

Source§

impl<T: Cast<u64>> BitSubset64<T>
where u64: Cast<T>,

Source

pub const fn from_tag_and_mask(tag: u64, mask: u64) -> Self

Source

pub const fn from_tag_and_superposition(tag: u64, sup: u64) -> Self

Source

pub const fn from_tag_and_union(tag: u64, union: u64) -> Self

Source

pub const fn from_tag(tag: u64) -> Self

Source

pub const fn has(self, value: u64) -> bool

Source

pub const fn union(self) -> u64

Source

pub const fn superposition(self) -> u64

Source

pub const fn or_unchecked(self, b: Self) -> Self

Source

pub const fn or(self, b: Self) -> Self

Source

pub const fn and(self, b: Self) -> Self

Source

pub const fn split(self, sub_mask: u64) -> (Self, Self)

Source

pub const fn raw_value_to_subset_value(self, value: u64) -> u64

Source

pub fn typed_value_to_subset_value(self, value: T) -> u64

Source

pub fn subset_value_to_typed_value(self, set: u64) -> T

Trait Implementations§

Source§

impl<T: Cast<u64>> Clone for BitSubset64<T>
where u64: Cast<T>,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Cast<u64>> Copy for BitSubset64<T>
where u64: Cast<T>,

Auto Trait Implementations§

§

impl<T> Freeze for BitSubset64<T>

§

impl<T> RefUnwindSafe for BitSubset64<T>
where T: RefUnwindSafe,

§

impl<T> Send for BitSubset64<T>
where T: Send,

§

impl<T> Sync for BitSubset64<T>
where T: Sync,

§

impl<T> Unpin for BitSubset64<T>
where T: Unpin,

§

impl<T> UnwindSafe for BitSubset64<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> RefMut for T

Source§

unsafe fn to_mut_ptr(&mut self) -> *mut Self

Source§

fn modify(&mut self, f: impl FnOnce(Self) -> Self)
where Self: Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.