Skip to main content

Znum

Struct Znum 

Source
pub struct Znum { /* private fields */ }
Expand description

Tracks which bits “may be 1s” (o) and “may be 0s” (z)

Compared to other bit domains, the Z domain requires minimal storage, which is not scaled with the number of operations, but as a result the accuracy of the domain is somewhat limited.

Implementations§

Source§

impl Znum

Source

pub const fn from_parts(ones: u64, zeros: u64) -> Self

Source

pub const fn from_value(v: u64) -> Self

From a value, generate a Znum

The resulting Znum only contains the provided value v, and no other values. It is considered a “constant”

Source

pub const fn is_const(&self) -> bool

Is there only a single contained value?

Source

pub const fn value(&self) -> Option<u64>

If this is a constant (only a single contained value), return that value. Otherwise, return None.

Source

pub const fn is_defined(&self) -> bool

Is any value contained in this?

In other words, are there no undefined bits?

Source

pub const fn contains_value(&self, v: u64) -> bool

Is a specific value contained in this?

Source

pub const fn union(&self, other: Self) -> Self

Return the least Z-domain containing every value in either operand.

Source

pub const fn contains(&self, other: Self) -> bool

self includes all possible elements in other

Source

pub const fn intersection(&self, other: Self) -> Self

Return the values represented by both operands.

Source

pub const fn has_value(&self) -> bool

Source

pub const fn max_value(&self) -> Option<u64>

Source

pub const fn min_value(&self) -> Option<u64>

Source

pub const fn unsigned_bounds(&self) -> Option<(u64, u64)>

Source

pub const fn signed_bounds(&self) -> Option<(i64, i64)>

Source

pub const fn bit_or(self, other: Self) -> Self

Source

pub const fn bit_and(self, other: Self) -> Self

Source

pub const fn bit_xor(self, other: Self) -> Self

Source

pub const fn bit_not(self) -> Self

Source

pub const fn add(self, other: Self) -> Self

Source

pub const fn subtract(self, other: Self) -> Self

Source

pub const fn shift_left(self, shift: u8) -> Self

Source

pub const fn shift_right(self, shift: u8) -> Self

Source

pub const fn negate(self) -> Self

Source

pub const fn multiply(self, other: Self) -> Self

Source

pub const fn checked_div(self, other: Self) -> Option<Self>

Divide by other, returning None when it can only be zero.

If other contains both zero and nonzero values, the result describes the divisions by its nonzero values.

Source

pub const fn divide(self, other: Self) -> Self

Source

pub const fn remainder(self, other: Self) -> Self

Trait Implementations§

Source§

impl Add for Znum

Source§

type Output = Znum

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
Source§

impl BitAnd for Znum

Source§

type Output = Znum

The resulting type after applying the & operator.
Source§

fn bitand(self, other: Self) -> Self

Performs the & operation. Read more
Source§

impl BitOr for Znum

Source§

type Output = Znum

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Self) -> Self

Performs the | operation. Read more
Source§

impl BitXor for Znum

Source§

type Output = Znum

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: Self) -> Self

Performs the ^ operation. Read more
Source§

impl Clone for Znum

Source§

fn clone(&self) -> Znum

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Znum

Source§

impl Debug for Znum

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Znum

Source§

fn default() -> Self

Default is a completely unknown value.

Source§

impl Div for Znum

Source§

type Output = Znum

The resulting type after applying the / operator.
Source§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
Source§

impl Eq for Znum

Source§

impl Mul for Znum

Source§

type Output = Znum

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
Source§

impl Neg for Znum

Source§

type Output = Znum

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl Not for Znum

Source§

type Output = Znum

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl PartialEq for Znum

Source§

fn eq(&self, other: &Znum) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Rem for Znum

Source§

type Output = Znum

The resulting type after applying the % operator.
Source§

fn rem(self, other: Self) -> Self

Performs the % operation. Read more
Source§

impl Shl<u8> for Znum

Source§

type Output = Znum

The resulting type after applying the << operator.
Source§

fn shl(self, shift: u8) -> Self

Performs the << operation. Read more
Source§

impl Shr<u8> for Znum

Source§

type Output = Znum

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: u8) -> Self

Performs the >> operation. Read more
Source§

impl StructuralPartialEq for Znum

Source§

impl Sub for Znum

Source§

type Output = Znum

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more

Auto Trait Implementations§

§

impl Freeze for Znum

§

impl RefUnwindSafe for Znum

§

impl Send for Znum

§

impl Sync for Znum

§

impl Unpin for Znum

§

impl UnsafeUnpin for Znum

§

impl UnwindSafe for Znum

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> 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.