Struct Bits
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§
§impl<const BITS: usize, const LIMBS: usize> Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Bits<BITS, LIMBS>
pub 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.
pub const fn into_inner(self) -> Uint<BITS, LIMBS>
pub const fn into_inner(self) -> Uint<BITS, LIMBS>
Returns the inner Uint.
pub 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.
§impl<const BITS: usize, const LIMBS: usize> Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Bits<BITS, LIMBS>
pub fn reverse_bits(self) -> Bits<BITS, LIMBS>
pub fn reverse_bits(self) -> Bits<BITS, LIMBS>
See Uint::reverse_bits
for documentation.
pub fn as_le_bytes(&self) -> Cow<'_, [u8]>
pub fn as_le_bytes(&self) -> Cow<'_, [u8]>
See Uint::as_le_bytes
for documentation.
pub 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.
pub 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.
pub 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.
pub fn leading_zeros(&self) -> usize
pub fn leading_zeros(&self) -> usize
See Uint::leading_zeros
for documentation.
pub fn leading_ones(&self) -> usize
pub fn leading_ones(&self) -> usize
See Uint::leading_ones
for documentation.
pub fn trailing_zeros(&self) -> usize
pub fn trailing_zeros(&self) -> usize
See Uint::trailing_zeros
for documentation.
pub fn trailing_ones(&self) -> usize
pub fn trailing_ones(&self) -> usize
See Uint::trailing_ones
for documentation.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub const fn as_limbs(&self) -> &[u64; LIMBS]
pub const fn as_limbs(&self) -> &[u64; LIMBS]
See Uint::as_limbs
for documentation.
Trait Implementations§
§impl<const BITS: usize, const LIMBS: usize> Arbitrary for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Arbitrary for Bits<BITS, LIMBS>
§type Parameters = <Uint<BITS, LIMBS> as Arbitrary>::Parameters
type Parameters = <Uint<BITS, LIMBS> as Arbitrary>::Parameters
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = Map<<Uint<BITS, LIMBS> as Arbitrary>::Strategy, fn(_: Uint<BITS, LIMBS>) -> Bits<BITS, LIMBS>>
type Strategy = Map<<Uint<BITS, LIMBS> as Arbitrary>::Strategy, fn(_: Uint<BITS, LIMBS>) -> Bits<BITS, LIMBS>>
Strategy
used to generate values of type Self
.§fn arbitrary_with(
args: <Bits<BITS, LIMBS> as Arbitrary>::Parameters,
) -> <Bits<BITS, LIMBS> as Arbitrary>::Strategy
fn arbitrary_with( args: <Bits<BITS, LIMBS> as Arbitrary>::Parameters, ) -> <Bits<BITS, LIMBS> as Arbitrary>::Strategy
§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>
§fn bitand_assign(&mut self, rhs: &Bits<BITS, LIMBS>)
fn bitand_assign(&mut self, rhs: &Bits<BITS, LIMBS>)
&=
operation. Read more§impl<const BITS: usize, const LIMBS: usize> BitAndAssign for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitAndAssign for Bits<BITS, LIMBS>
§fn bitand_assign(&mut self, rhs: Bits<BITS, LIMBS>)
fn bitand_assign(&mut self, rhs: Bits<BITS, LIMBS>)
&=
operation. Read more§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>
§fn bitor_assign(&mut self, rhs: &Bits<BITS, LIMBS>)
fn bitor_assign(&mut self, rhs: &Bits<BITS, LIMBS>)
|=
operation. Read more§impl<const BITS: usize, const LIMBS: usize> BitOrAssign for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitOrAssign for Bits<BITS, LIMBS>
§fn bitor_assign(&mut self, rhs: Bits<BITS, LIMBS>)
fn bitor_assign(&mut self, rhs: Bits<BITS, LIMBS>)
|=
operation. Read more§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>
§fn bitxor_assign(&mut self, rhs: &Bits<BITS, LIMBS>)
fn bitxor_assign(&mut self, rhs: &Bits<BITS, LIMBS>)
^=
operation. Read more§impl<const BITS: usize, const LIMBS: usize> BitXorAssign for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitXorAssign for Bits<BITS, LIMBS>
§fn bitxor_assign(&mut self, rhs: Bits<BITS, LIMBS>)
fn bitxor_assign(&mut self, rhs: Bits<BITS, LIMBS>)
^=
operation. Read more§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>
§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>,
§impl<const BITS: usize, const LIMBS: usize> Serialize for Bits<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Serialize for Bits<BITS, LIMBS>
§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,
§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>
§fn shl_assign(&mut self, rhs: &usize)
fn shl_assign(&mut self, rhs: &usize)
<<=
operation. Read more§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>
§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
<<=
operation. Read more§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>
§fn shr_assign(&mut self, rhs: &usize)
fn shr_assign(&mut self, rhs: &usize)
>>=
operation. Read more§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>
§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,
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FmtForward for T
impl<T> FmtForward for T
§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.§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.§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.§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.§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.§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.§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.§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.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§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 more§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 more§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
§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
§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.§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.§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.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§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 more§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 more§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 more§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 more§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 more§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 more§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.§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.§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.§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.§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.§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.§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.§impl<T> TryConv for T
impl<T> TryConv for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeDebug for Twhere
T: Debug,
impl<T> MaybeSendSync for T
impl<T> MaybeSerde for Twhere
T: Serialize + for<'de> Deserialize<'de>,
impl<T> NippyJarHeader for T
impl<T> RpcObject for Twhere
T: RpcParam + RpcReturn,
impl<T> RpcParam for T
impl<T> RpcReturn for T
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.