ruint

Struct Bits

Source
pub struct Bits<const BITS: usize, const LIMBS: usize>(/* private fields */);
Expand description

A newtype wrapper around Uint that restricts operations to those relevant for bit arrays.

Implementations§

Source§

impl<const BITS: usize, const LIMBS: usize> Bits<BITS, LIMBS>

Source

pub const LIMBS: usize = Uint<BITS, LIMBS>::LIMBS

The size of this integer type in 64-bit limbs.

Source

pub const BITS: usize = Uint<BITS, LIMBS>::BITS

The size of this integer type in bits.

Source

pub const BYTES: usize = Uint<BITS, LIMBS>::BYTES

The size of this integer type in bits.

Source

pub const ZERO: Self = _

The value zero. This is the only value that exists in all Uint types.

Source

pub const fn into_inner(self) -> Uint<BITS, LIMBS>

Returns the inner Uint.

Source

pub const fn as_uint(&self) -> &Uint<BITS, LIMBS>

Returns a reference to the inner Uint.

Source

pub fn as_uint_mut(&mut self) -> &mut Uint<BITS, LIMBS>

Returns a mutable reference to the inner Uint.

Source§

impl<const BITS: usize, const LIMBS: usize> Bits<BITS, LIMBS>

Source

pub fn reverse_bits(self) -> Self

See Uint::reverse_bits for documentation.

Source

pub fn as_le_bytes(&self) -> Cow<'_, [u8]>

See Uint::as_le_bytes for documentation.

Source

pub fn to_be_bytes_vec(&self) -> Vec<u8>

See Uint::to_be_bytes_vec for documentation.

Source

pub fn to_le_bytes<const BYTES: usize>(&self) -> [u8; BYTES]

See Uint::to_le_bytes for documentation.

Source

pub fn to_be_bytes<const BYTES: usize>(&self) -> [u8; BYTES]

See Uint::to_be_bytes for documentation.

Source

pub fn leading_zeros(&self) -> usize

See Uint::leading_zeros for documentation.

Source

pub fn leading_ones(&self) -> usize

See Uint::leading_ones for documentation.

Source

pub fn trailing_zeros(&self) -> usize

See Uint::trailing_zeros for documentation.

Source

pub fn trailing_ones(&self) -> usize

See Uint::trailing_ones for documentation.

Source

pub unsafe fn as_limbs_mut(&mut self) -> &mut [u64; LIMBS]

See Uint::as_limbs_mut for documentation.

Source

pub fn checked_shl(self, rhs: usize) -> Option<Self>

See Uint::checked_shl for documentation.

Source

pub fn checked_shr(self, rhs: usize) -> Option<Self>

See Uint::checked_shr for documentation.

Source

pub fn overflowing_shl(self, rhs: usize) -> (Self, bool)

See Uint::overflowing_shl for documentation.

Source

pub fn overflowing_shr(self, rhs: usize) -> (Self, bool)

See Uint::overflowing_shr for documentation.

Source

pub fn wrapping_shl(self, rhs: usize) -> Self

See Uint::wrapping_shl for documentation.

Source

pub fn wrapping_shr(self, rhs: usize) -> Self

See Uint::wrapping_shr for documentation.

Source

pub fn rotate_left(self, rhs: usize) -> Self

See Uint::rotate_left for documentation.

Source

pub fn rotate_right(self, rhs: usize) -> Self

See Uint::rotate_right for documentation.

Source

pub fn try_from_be_slice(bytes: &[u8]) -> Option<Self>

See Uint::try_from_be_slice for documentation.

Source

pub fn try_from_le_slice(bytes: &[u8]) -> Option<Self>

See Uint::try_from_le_slice for documentation.

Source

pub fn from_str_radix(src: &str, radix: u64) -> Result<Self, ParseError>

See Uint::from_str_radix for documentation.

Source

pub fn from_be_bytes<const BYTES: usize>(bytes: [u8; BYTES]) -> Self

See Uint::from_be_bytes for documentation.

Source

pub fn from_le_bytes<const BYTES: usize>(bytes: [u8; BYTES]) -> Self

See Uint::from_le_bytes for documentation.

Source

pub const fn from_limbs(limbs: [u64; LIMBS]) -> Self

See Uint::from_limbs for documentation.

Source

pub const fn as_limbs(&self) -> &[u64; LIMBS]

See Uint::as_limbs for documentation.

Trait Implementations§

Source§

impl<const BITS: usize, const LIMBS: usize> BitAnd<&Bits<BITS, LIMBS>> for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &Bits<BITS, LIMBS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitAnd<&Bits<BITS, LIMBS>> for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &Bits<BITS, LIMBS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitAnd<Bits<BITS, LIMBS>> for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Bits<BITS, LIMBS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitAnd for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Bits<BITS, LIMBS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitAndAssign<&Bits<BITS, LIMBS>> for Bits<BITS, LIMBS>

Source§

fn bitand_assign(&mut self, rhs: &Bits<BITS, LIMBS>)

Performs the &= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitAndAssign for Bits<BITS, LIMBS>

Source§

fn bitand_assign(&mut self, rhs: Bits<BITS, LIMBS>)

Performs the &= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitOr<&Bits<BITS, LIMBS>> for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &Bits<BITS, LIMBS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitOr<&Bits<BITS, LIMBS>> for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &Bits<BITS, LIMBS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitOr<Bits<BITS, LIMBS>> for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Bits<BITS, LIMBS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitOr for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Bits<BITS, LIMBS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitOrAssign<&Bits<BITS, LIMBS>> for Bits<BITS, LIMBS>

Source§

fn bitor_assign(&mut self, rhs: &Bits<BITS, LIMBS>)

Performs the |= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitOrAssign for Bits<BITS, LIMBS>

Source§

fn bitor_assign(&mut self, rhs: Bits<BITS, LIMBS>)

Performs the |= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitXor<&Bits<BITS, LIMBS>> for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &Bits<BITS, LIMBS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitXor<&Bits<BITS, LIMBS>> for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &Bits<BITS, LIMBS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitXor<Bits<BITS, LIMBS>> for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Bits<BITS, LIMBS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitXor for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Bits<BITS, LIMBS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitXorAssign<&Bits<BITS, LIMBS>> for Bits<BITS, LIMBS>

Source§

fn bitxor_assign(&mut self, rhs: &Bits<BITS, LIMBS>)

Performs the ^= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitXorAssign for Bits<BITS, LIMBS>

Source§

fn bitxor_assign(&mut self, rhs: Bits<BITS, LIMBS>)

Performs the ^= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Clone for Bits<BITS, LIMBS>

Source§

fn clone(&self) -> Bits<BITS, LIMBS>

Returns a copy 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<const BITS: usize, const LIMBS: usize> Debug for Bits<BITS, LIMBS>

Source§

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

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

impl<const BITS: usize, const LIMBS: usize> Default for Bits<BITS, LIMBS>

Source§

fn default() -> Bits<BITS, LIMBS>

Returns the “default value” for a type. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> From<Bits<BITS, LIMBS>> for Uint<BITS, LIMBS>

Source§

fn from(value: Bits<BITS, LIMBS>) -> Self

Converts to this type from the input type.
Source§

impl<const BITS: usize, const LIMBS: usize> From<Uint<BITS, LIMBS>> for Bits<BITS, LIMBS>

Source§

fn from(value: Uint<BITS, LIMBS>) -> Self

Converts to this type from the input type.
Source§

impl<const BITS: usize, const LIMBS: usize> FromStr for Bits<BITS, LIMBS>

Source§

type Err = <Uint<BITS, LIMBS> as FromStr>::Err

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Hash for Bits<BITS, LIMBS>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Index<usize> for Bits<BITS, LIMBS>

Source§

type Output = bool

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Not for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Bits<BITS, LIMBS>

Performs the unary ! operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Not for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> PartialEq for Bits<BITS, LIMBS>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<&usize> for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

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

fn shl(self, rhs: &usize) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<&usize> for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

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

fn shl(self, rhs: &usize) -> Self

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<usize> for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

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

fn shl(self, rhs: usize) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<usize> for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

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

fn shl(self, rhs: usize) -> Self

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<&usize> for Bits<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: &usize)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<usize> for Bits<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: usize)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<&usize> for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

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

fn shr(self, rhs: &usize) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<&usize> for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

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

fn shr(self, rhs: &usize) -> Self

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<usize> for &Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

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

fn shr(self, rhs: usize) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<usize> for Bits<BITS, LIMBS>

Source§

type Output = Bits<BITS, LIMBS>

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

fn shr(self, rhs: usize) -> Self

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<&usize> for Bits<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: &usize)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<usize> for Bits<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: usize)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Copy for Bits<BITS, LIMBS>

Source§

impl<const BITS: usize, const LIMBS: usize> Eq for Bits<BITS, LIMBS>

Source§

impl<const BITS: usize, const LIMBS: usize> StructuralPartialEq for Bits<BITS, LIMBS>

Auto Trait Implementations§

§

impl<const BITS: usize, const LIMBS: usize> Freeze for Bits<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> RefUnwindSafe for Bits<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> Send for Bits<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> Sync for Bits<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> Unpin for Bits<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> UnwindSafe for Bits<BITS, LIMBS>

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dst. 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.