Skip to main content

Bits

Struct Bits 

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

Which bits of a value are known, and what they are.

A set bit in unknown means that bit could be either. A clear one means value has it. The two are kept canonical, so a bit that is unknown is zero in value, which makes equality mean what it looks like.

Implementations§

Source§

impl Bits

Source

pub const fn unknown(width: u32) -> Self

Nothing known at this width.

Source

pub const fn exactly(value: u128, width: u32) -> Self

Every bit known, and these are they.

Source

pub const fn known(self, width: u32) -> u128

The bits that are known, as a mask.

Source

pub const fn value(self) -> u128

What the known bits are, with the unknown ones zero.

Source

pub const fn min(self) -> u128

The smallest value these bits allow, which is the unknown ones all zero.

Source

pub const fn max(self) -> u128

The largest, which is the unknown ones all one.

Source

pub const fn allows(self, value: u128) -> bool

Whether this value is one these bits allow.

Source

pub const fn from_parts(value: u128, unknown: u128, width: u32) -> Self

Bits from a value and a mask of which of them mean nothing.

This is the way in for an operation that worked out its answer a bit at a time, which is every bitwise operation. The value is canonicalized, so a bit that is unknown comes back zero however it went in.

Source

pub const fn unknown_bits(self) -> u128

The bits that mean nothing, as a mask.

Source

pub const fn low_zeros(self) -> u32

How many low bits are known to be zero, which is what says a value is a multiple of a power of two and so what an alignment fact is made of.

Source

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

Everything both of these know, or None when they contradict each other.

A contradiction is not a failure. It is the proof that whatever produced the two facts is on a path that is never taken, and the caller turns it into the empty range.

Source

pub fn join(self, other: Self) -> Self

Only what both of these agree on, which is what a value from either place is known to be.

Trait Implementations§

Source§

impl Clone for Bits

Source§

fn clone(&self) -> Bits

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 Bits

Source§

impl Debug for Bits

Source§

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

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

impl Eq for Bits

Source§

impl PartialEq for Bits

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Bits

Auto Trait Implementations§

§

impl Freeze for Bits

§

impl RefUnwindSafe for Bits

§

impl Send for Bits

§

impl Sync for Bits

§

impl Unpin for Bits

§

impl UnsafeUnpin for Bits

§

impl UnwindSafe for Bits

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.