Type Alias FieldBits

Source
pub type FieldBits<V> = BitArray<V, Lsb0>;
Expand description

Bit representation of a field element.

Aliased Type§

struct FieldBits<V> {
    pub _ord: PhantomData<Lsb0>,
    pub data: V,
}

Fields§

§_ord: PhantomData<Lsb0>

The ordering of bits within an A::Store element.

§data: V

The wrapped data buffer.

Implementations

Source§

impl<A, O> BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source

pub const ZERO: BitArray<A, O>

A bit-array with all bits initialized to zero.

Source

pub fn new(data: A) -> BitArray<A, O>

Wraps an existing buffer as a bit-array.

§Examples
use bitvec::prelude::*;

let data = [0u16, 1, 2, 3];
let bits = BitArray::<_, Msb0>::new(data);
assert_eq!(bits.len(), 64);
Source

pub fn into_inner(self) -> A

Removes the bit-array wrapper, returning the contained buffer.

§Examples
use bitvec::prelude::*;

let bits = bitarr![0; 30];
let native: [usize; 1] = bits.into_inner();
Source

pub fn as_bitslice(&self) -> &BitSlice<<A as BitView>::Store, O>

Explicitly views the bit-array as a bit-slice.

Source

pub fn as_mut_bitslice(&mut self) -> &mut BitSlice<<A as BitView>::Store, O>

Explicitly views the bit-array as a mutable bit-slice.

Source

pub fn as_raw_slice(&self) -> &[<A as BitView>::Store]

Views the bit-array as a slice of its underlying memory elements.

Source

pub fn as_raw_mut_slice(&mut self) -> &mut [<A as BitView>::Store]

Views the bit-array as a mutable slice of its underlying memory elements.

Source

pub fn len(&self) -> usize

Gets the length (in bits) of the bit-array.

This method is a compile-time constant.

Source

pub fn is_empty(&self) -> bool

Tests whether the array is empty.

This method is a compile-time constant.

Source§

impl<A, O> BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source

pub fn as_slice(&self) -> &BitSlice<<A as BitView>::Store, O>

👎Deprecated: use .as_bitslice() or .as_raw_slice() instead

Returns a bit-slice containing the entire bit-array. Equivalent to &a[..].

Because BitArray can be viewed as a slice of bits or as a slice of elements with equal ease, you should switch to using .as_bitslice() or .as_raw_slice() to make your choice explicit.

§Original

array::as_slice

Source

pub fn as_mut_slice(&mut self) -> &mut BitSlice<<A as BitView>::Store, O>

👎Deprecated: use .as_mut_bitslice() or .as_raw_mut_slice() instead

Returns a mutable bit-slice containing the entire bit-array. Equivalent to &mut a[..].

Because BitArray can be viewed as a slice of bits or as a slice of elements with equal ease, you should switch to using .as_mut_bitslice() or .as_raw_mut_slice() to make your choice explicit.

§Original

array::as_mut_slice

Trait Implementations

Source§

impl<A, O> AsMut<BitSlice<<A as BitView>::Store, O>> for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

fn as_mut(&mut self) -> &mut BitSlice<<A as BitView>::Store, O>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<A, O> AsRef<BitSlice<<A as BitView>::Store, O>> for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

fn as_ref(&self) -> &BitSlice<<A as BitView>::Store, O>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<A, O> Binary for BitArray<A, O>
where O: BitOrder, A: BitViewSized,

Source§

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

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

impl<A, O, Rhs> BitAnd<Rhs> for BitArray<A, O>
where A: BitViewSized, O: BitOrder, BitSlice<<A as BitView>::Store, O>: BitAndAssign<Rhs>,

Source§

type Output = BitArray<A, O>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Rhs) -> <BitArray<A, O> as BitAnd<Rhs>>::Output

Performs the & operation. Read more
Source§

impl<A, O, Rhs> BitAndAssign<Rhs> for BitArray<A, O>
where A: BitViewSized, O: BitOrder, BitSlice<<A as BitView>::Store, O>: BitAndAssign<Rhs>,

Source§

fn bitand_assign(&mut self, rhs: Rhs)

Performs the &= operation. Read more
Source§

impl<A, O> BitField for BitArray<A, O>
where O: BitOrder, A: BitViewSized, BitSlice<<A as BitView>::Store, O>: BitField,

§Bit-Array Implementation of BitField

The BitArray implementation is only ever called when the entire bit-array is available for use, which means it can skip the bit-slice memory detection and instead use the underlying storage elements directly.

The implementation still performs the segmentation for each element contained in the array, in order to maintain value consistency so that viewing the array as a bit-slice is still able to correctly interact with data contained in it.

Source§

fn load_le<I>(&self) -> I
where I: Integral,

Little-Endian Integer Loading Read more
Source§

fn load_be<I>(&self) -> I
where I: Integral,

Big-Endian Integer Loading Read more
Source§

fn store_le<I>(&mut self, value: I)
where I: Integral,

Little-Endian Integer Storing Read more
Source§

fn store_be<I>(&mut self, value: I)
where I: Integral,

Big-Endian Integer Storing Read more
Source§

fn load<I>(&self) -> I
where I: Integral,

Integer Loading Read more
Source§

fn store<I>(&mut self, value: I)
where I: Integral,

Integer Storing Read more
Source§

impl<A, O, Rhs> BitOr<Rhs> for BitArray<A, O>
where A: BitViewSized, O: BitOrder, BitSlice<<A as BitView>::Store, O>: BitOrAssign<Rhs>,

Source§

type Output = BitArray<A, O>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Rhs) -> <BitArray<A, O> as BitOr<Rhs>>::Output

Performs the | operation. Read more
Source§

impl<A, O, Rhs> BitOrAssign<Rhs> for BitArray<A, O>
where A: BitViewSized, O: BitOrder, BitSlice<<A as BitView>::Store, O>: BitOrAssign<Rhs>,

Source§

fn bitor_assign(&mut self, rhs: Rhs)

Performs the |= operation. Read more
Source§

impl<A, O, Rhs> BitXor<Rhs> for BitArray<A, O>
where A: BitViewSized, O: BitOrder, BitSlice<<A as BitView>::Store, O>: BitXorAssign<Rhs>,

Source§

type Output = BitArray<A, O>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Rhs) -> <BitArray<A, O> as BitXor<Rhs>>::Output

Performs the ^ operation. Read more
Source§

impl<A, O, Rhs> BitXorAssign<Rhs> for BitArray<A, O>
where A: BitViewSized, O: BitOrder, BitSlice<<A as BitView>::Store, O>: BitXorAssign<Rhs>,

Source§

fn bitxor_assign(&mut self, rhs: Rhs)

Performs the ^= operation. Read more
Source§

impl<A, O> Borrow<BitSlice<<A as BitView>::Store, O>> for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

fn borrow(&self) -> &BitSlice<<A as BitView>::Store, O>

Immutably borrows from an owned value. Read more
Source§

impl<A, O> BorrowMut<BitSlice<<A as BitView>::Store, O>> for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

fn borrow_mut(&mut self) -> &mut BitSlice<<A as BitView>::Store, O>

Mutably borrows from an owned value. Read more
Source§

impl<A, O> Clone for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

fn clone(&self) -> BitArray<A, O>

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<A, O> Debug for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

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

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

impl<A, O> Default for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

fn default() -> BitArray<A, O>

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

impl<A, O> Deref for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

type Target = BitSlice<<A as BitView>::Store, O>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<BitArray<A, O> as Deref>::Target

Dereferences the value.
Source§

impl<A, O> DerefMut for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

fn deref_mut(&mut self) -> &mut <BitArray<A, O> as Deref>::Target

Mutably dereferences the value.
Source§

impl<A, O> Display for BitArray<A, O>
where O: BitOrder, A: BitViewSized,

Source§

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

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

impl<A, O> From<A> for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

fn from(data: A) -> BitArray<A, O>

Converts to this type from the input type.
Source§

impl<A, O> Hash for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

fn hash<H>(&self, hasher: &mut H)
where H: Hasher,

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<A, O, Idx> Index<Idx> for BitArray<A, O>
where A: BitViewSized, O: BitOrder, BitSlice<<A as BitView>::Store, O>: Index<Idx>,

Source§

type Output = <BitSlice<<A as BitView>::Store, O> as Index<Idx>>::Output

The returned type after indexing.
Source§

fn index(&self, index: Idx) -> &<BitArray<A, O> as Index<Idx>>::Output

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

impl<A, O, Idx> IndexMut<Idx> for BitArray<A, O>
where A: BitViewSized, O: BitOrder, BitSlice<<A as BitView>::Store, O>: IndexMut<Idx>,

Source§

fn index_mut( &mut self, index: Idx, ) -> &mut <BitArray<A, O> as Index<Idx>>::Output

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

impl<A, O> IntoIterator for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

type IntoIter = IntoIter<A, O>

Which kind of iterator are we turning this into?
Source§

type Item = <IntoIter<A, O> as Iterator>::Item

The type of the elements being iterated over.
Source§

fn into_iter(self) -> <BitArray<A, O> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<A, O> LowerHex for BitArray<A, O>
where O: BitOrder, A: BitViewSized,

Source§

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

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

impl<A, O> Not for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

type Output = BitArray<A, O>

The resulting type after applying the ! operator.
Source§

fn not(self) -> <BitArray<A, O> as Not>::Output

Performs the unary ! operation. Read more
Source§

impl<A, O> Octal for BitArray<A, O>
where O: BitOrder, A: BitViewSized,

Source§

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

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

impl<A, O> Ord for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

fn cmp(&self, other: &BitArray<A, O>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<A, O, Rhs> PartialEq<Rhs> for BitArray<A, O>
where A: BitViewSized, O: BitOrder, BitSlice<<A as BitView>::Store, O>: PartialEq<Rhs>, Rhs: ?Sized,

Source§

fn eq(&self, other: &Rhs) -> 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<A, O, Rhs> PartialOrd<Rhs> for BitArray<A, O>
where A: BitViewSized, O: BitOrder, BitSlice<<A as BitView>::Store, O>: PartialOrd<Rhs>, Rhs: ?Sized,

Source§

fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<A, O> TryFrom<&BitSlice<<A as BitView>::Store, O>> for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

type Error = TryFromBitSliceError

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

fn try_from( src: &BitSlice<<A as BitView>::Store, O>, ) -> Result<BitArray<A, O>, <BitArray<A, O> as TryFrom<&BitSlice<<A as BitView>::Store, O>>>::Error>

Performs the conversion.
Source§

impl<A, O> UpperHex for BitArray<A, O>
where O: BitOrder, A: BitViewSized,

Source§

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

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

impl<A, O> Copy for BitArray<A, O>
where O: BitOrder, A: BitViewSized + Copy,

Source§

impl<A, O> Eq for BitArray<A, O>
where A: BitViewSized, O: BitOrder,

Source§

impl<A, O> Unpin for BitArray<A, O>
where A: BitViewSized, O: BitOrder,