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>
impl<const BITS: usize, const LIMBS: usize> Bits<BITS, LIMBS>
Sourcepub const LIMBS: usize = Uint<BITS, LIMBS>::LIMBS
pub const LIMBS: usize = Uint<BITS, LIMBS>::LIMBS
The size of this integer type in 64-bit limbs.
Sourcepub const ZERO: Bits<BITS, LIMBS>
pub const ZERO: Bits<BITS, LIMBS>
The value zero. This is the only value that exists in all Uint
types.
Sourcepub const fn into_inner(self) -> Uint<BITS, LIMBS>
pub const fn into_inner(self) -> Uint<BITS, LIMBS>
Returns the inner Uint.
Sourcepub fn as_uint_mut(&mut self) -> &mut Uint<BITS, LIMBS>
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>
impl<const BITS: usize, const LIMBS: usize> Bits<BITS, LIMBS>
Sourcepub fn reverse_bits(self) -> Bits<BITS, LIMBS>
pub fn reverse_bits(self) -> Bits<BITS, LIMBS>
See Uint::reverse_bits
for documentation.
Sourcepub fn as_le_bytes(&self) -> Cow<'_, [u8]>
pub fn as_le_bytes(&self) -> Cow<'_, [u8]>
See Uint::as_le_bytes
for documentation.
Sourcepub fn to_be_bytes_vec(&self) -> Vec<u8> ⓘ
pub fn to_be_bytes_vec(&self) -> Vec<u8> ⓘ
See Uint::to_be_bytes_vec
for documentation.
Sourcepub fn to_le_bytes<const BYTES: usize>(&self) -> [u8; BYTES]
pub fn to_le_bytes<const BYTES: usize>(&self) -> [u8; BYTES]
See Uint::to_le_bytes
for documentation.
Sourcepub fn to_be_bytes<const BYTES: usize>(&self) -> [u8; BYTES]
pub fn to_be_bytes<const BYTES: usize>(&self) -> [u8; BYTES]
See Uint::to_be_bytes
for documentation.
Sourcepub fn leading_zeros(&self) -> usize
pub fn leading_zeros(&self) -> usize
See Uint::leading_zeros
for documentation.
Sourcepub fn leading_ones(&self) -> usize
pub fn leading_ones(&self) -> usize
See Uint::leading_ones
for documentation.
Sourcepub fn trailing_zeros(&self) -> usize
pub fn trailing_zeros(&self) -> usize
See Uint::trailing_zeros
for documentation.
Sourcepub fn trailing_ones(&self) -> usize
pub fn trailing_ones(&self) -> usize
See Uint::trailing_ones
for documentation.
Sourcepub unsafe fn as_limbs_mut(&mut self) -> &mut [u64; LIMBS]
pub unsafe fn as_limbs_mut(&mut self) -> &mut [u64; LIMBS]
See Uint::as_limbs_mut
for documentation.
Sourcepub fn checked_shl(self, rhs: usize) -> Option<Bits<BITS, LIMBS>>
pub fn checked_shl(self, rhs: usize) -> Option<Bits<BITS, LIMBS>>
See Uint::checked_shl
for documentation.
Sourcepub fn checked_shr(self, rhs: usize) -> Option<Bits<BITS, LIMBS>>
pub fn checked_shr(self, rhs: usize) -> Option<Bits<BITS, LIMBS>>
See Uint::checked_shr
for documentation.
Sourcepub fn overflowing_shl(self, rhs: usize) -> (Bits<BITS, LIMBS>, bool)
pub fn overflowing_shl(self, rhs: usize) -> (Bits<BITS, LIMBS>, bool)
See Uint::overflowing_shl
for documentation.
Sourcepub fn overflowing_shr(self, rhs: usize) -> (Bits<BITS, LIMBS>, bool)
pub fn overflowing_shr(self, rhs: usize) -> (Bits<BITS, LIMBS>, bool)
See Uint::overflowing_shr
for documentation.
Sourcepub fn wrapping_shl(self, rhs: usize) -> Bits<BITS, LIMBS>
pub fn wrapping_shl(self, rhs: usize) -> Bits<BITS, LIMBS>
See Uint::wrapping_shl
for documentation.
Sourcepub fn wrapping_shr(self, rhs: usize) -> Bits<BITS, LIMBS>
pub fn wrapping_shr(self, rhs: usize) -> Bits<BITS, LIMBS>
See Uint::wrapping_shr
for documentation.
Sourcepub fn rotate_left(self, rhs: usize) -> Bits<BITS, LIMBS>
pub fn rotate_left(self, rhs: usize) -> Bits<BITS, LIMBS>
See Uint::rotate_left
for documentation.
Sourcepub fn rotate_right(self, rhs: usize) -> Bits<BITS, LIMBS>
pub fn rotate_right(self, rhs: usize) -> Bits<BITS, LIMBS>
See Uint::rotate_right
for documentation.
Sourcepub fn try_from_be_slice(bytes: &[u8]) -> Option<Bits<BITS, LIMBS>>
pub fn try_from_be_slice(bytes: &[u8]) -> Option<Bits<BITS, LIMBS>>
See Uint::try_from_be_slice
for documentation.
Sourcepub fn try_from_le_slice(bytes: &[u8]) -> Option<Bits<BITS, LIMBS>>
pub fn try_from_le_slice(bytes: &[u8]) -> Option<Bits<BITS, LIMBS>>
See Uint::try_from_le_slice
for documentation.
Sourcepub fn from_str_radix(
src: &str,
radix: u64,
) -> Result<Bits<BITS, LIMBS>, ParseError>
pub fn from_str_radix( src: &str, radix: u64, ) -> Result<Bits<BITS, LIMBS>, ParseError>
See Uint::from_str_radix
for documentation.
Sourcepub fn from_be_bytes<const BYTES: usize>(
bytes: [u8; BYTES],
) -> Bits<BITS, LIMBS>
pub fn from_be_bytes<const BYTES: usize>( bytes: [u8; BYTES], ) -> Bits<BITS, LIMBS>
See Uint::from_be_bytes
for documentation.
Sourcepub fn from_le_bytes<const BYTES: usize>(
bytes: [u8; BYTES],
) -> Bits<BITS, LIMBS>
pub fn from_le_bytes<const BYTES: usize>( bytes: [u8; BYTES], ) -> Bits<BITS, LIMBS>
See Uint::from_le_bytes
for documentation.
Sourcepub const fn from_limbs(limbs: [u64; LIMBS]) -> Bits<BITS, LIMBS>
pub const fn from_limbs(limbs: [u64; LIMBS]) -> Bits<BITS, LIMBS>
See Uint::from_limbs
for documentation.
Sourcepub const fn as_limbs(&self) -> &[u64; LIMBS]
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>
impl<const BITS: usize, const LIMBS: usize> BitAnd<&Bits<BITS, LIMBS>> for &Bits<BITS, LIMBS>
Source§impl<const BITS: usize, const LIMBS: usize> BitAndAssign<&Bits<BITS, LIMBS>> for Bits<BITS, LIMBS>
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>)
fn bitand_assign(&mut self, rhs: &Bits<BITS, LIMBS>)
&=
operation. Read moreSource§impl<const BITS: usize, const LIMBS: usize> BitAndAssign for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitAndAssign for Bits<BITS, LIMBS>
Source§fn bitand_assign(&mut self, rhs: Bits<BITS, LIMBS>)
fn bitand_assign(&mut self, rhs: Bits<BITS, LIMBS>)
&=
operation. Read moreSource§impl<const BITS: usize, const LIMBS: usize> BitOrAssign<&Bits<BITS, LIMBS>> for Bits<BITS, LIMBS>
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>)
fn bitor_assign(&mut self, rhs: &Bits<BITS, LIMBS>)
|=
operation. Read moreSource§impl<const BITS: usize, const LIMBS: usize> BitOrAssign for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitOrAssign for Bits<BITS, LIMBS>
Source§fn bitor_assign(&mut self, rhs: Bits<BITS, LIMBS>)
fn bitor_assign(&mut self, rhs: Bits<BITS, LIMBS>)
|=
operation. Read moreSource§impl<const BITS: usize, const LIMBS: usize> BitXor<&Bits<BITS, LIMBS>> for &Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitXor<&Bits<BITS, LIMBS>> for &Bits<BITS, LIMBS>
Source§impl<const BITS: usize, const LIMBS: usize> BitXorAssign<&Bits<BITS, LIMBS>> for Bits<BITS, LIMBS>
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>)
fn bitxor_assign(&mut self, rhs: &Bits<BITS, LIMBS>)
^=
operation. Read moreSource§impl<const BITS: usize, const LIMBS: usize> BitXorAssign for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitXorAssign for Bits<BITS, LIMBS>
Source§fn bitxor_assign(&mut self, rhs: Bits<BITS, LIMBS>)
fn bitxor_assign(&mut self, rhs: Bits<BITS, LIMBS>)
^=
operation. Read moreSource§impl<'de, const BITS: usize, const LIMBS: usize> Deserialize<'de> for Bits<BITS, LIMBS>
impl<'de, const BITS: usize, const LIMBS: usize> Deserialize<'de> for Bits<BITS, LIMBS>
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Bits<BITS, LIMBS>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Bits<BITS, LIMBS>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<const BITS: usize, const LIMBS: usize> Serialize for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Serialize for Bits<BITS, LIMBS>
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl<const BITS: usize, const LIMBS: usize> ShlAssign<&usize> for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> ShlAssign<&usize> for Bits<BITS, LIMBS>
Source§fn shl_assign(&mut self, rhs: &usize)
fn shl_assign(&mut self, rhs: &usize)
<<=
operation. Read moreSource§impl<const BITS: usize, const LIMBS: usize> ShlAssign<usize> for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> ShlAssign<usize> for Bits<BITS, LIMBS>
Source§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
<<=
operation. Read moreSource§impl<const BITS: usize, const LIMBS: usize> ShrAssign<&usize> for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> ShrAssign<&usize> for Bits<BITS, LIMBS>
Source§fn shr_assign(&mut self, rhs: &usize)
fn shr_assign(&mut self, rhs: &usize)
>>=
operation. Read moreSource§impl<const BITS: usize, const LIMBS: usize> ShrAssign<usize> for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> ShrAssign<usize> for Bits<BITS, LIMBS>
Source§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>=
operation. Read moreimpl<const BITS: usize, const LIMBS: usize> Copy for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Eq for Bits<BITS, LIMBS>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.