pub struct BitArray<const N: usize, Word: Unsigned = usize, const WORDS: usize = { N.div_ceil(Word::UBITS) }> { /* private fields */ }Expand description
§The BitArray Type
§Introduction
A BitArray is a fixed sized vector of bit elements stored compactly in an array of unsigned integer words.
The default word type is usize.
The type implements the BitStore trait, which provides a rich API for manipulating the bits in the vector.
In addition to the many methods defined by the BitStore trait, the BitArray type provides several ways to construct bit-arrays from various sources.
A BitArray packs its elements into a standard array of some unsigned integer type defined by the generic parameter of type Unsigned.
The default Word is a usize which, on modern computer systems, will often be a 64-bit unsigned integer.
Operations on and between bit-arrays and other objects in the gf2 crate are implemented using bitwise operations on whole underlying words at a time.
These are highly optimised in modern CPUs, allowing for fast computation even on large bit-arrays.
It also means we never have to worry about overflows or carries as we would with normal integer arithmetic.
In mathematical terms, a bit-array is a vector over GF(2), the simplest Galois-Field with just two elements, usually denoted 0 & 1, as the booleans true & false, or as the bits set & unset.
Arithmetic over GF(2) is mod 2, so addition/subtraction becomes the XOR operation while multiplication/division becomes AND.
It is worth noting that by default, a BitArray prints in vector-order.
For example, a bit-vector of size four will print as v0v1v2v3 with the elements in increasing index-order with the “least significant” vector element, v0, coming first on the left.
This contrasts to the many bit-set types, which usually print in bit-order.
The equivalent object in those libraries with say four elements prints as b3b2b1b0 with the least significant bit b0 printed last on the right.
Of course, for many applications, printing in bit-order makes perfect sense.
A size four bit-array initialized with the hex number 0x1 will print as 1000.
A bit-ordered version prints the same value as 0001, which will be more natural in some settings.
However, our main aim is numerical work, where vector order is more natural. In particular, bit-order is unnatural for matrices over GF(2). It is too confusing to print a matrix in any order other than the one where the (0,0) element is at the top left, and proceed from there.
§Methods Overview
The BitArray type implements the BitStore trait and also provides several methods for constructing bit-arrays:
| Category | Description |
|---|---|
| Trait Requirements | Methods needed to implement the BitStore trait. |
| Constructors | Methods to create bit-arrays with specific properties and fills. |
The type also inherits dozens of associated methods from the BitStore trait.
These methods fall into categories:
| Inherited Category | Description |
|---|---|
| Bit Access | Methods to access individual bit elements in a bit-array. |
| Queries | Methods to query the overall state of a bit-array. |
| Mutators | Methods to mutate the overall state of a bit-array. |
| Copies & Fills | Methods to fill a bit-array from various sources. |
| Slices | Methods to create non-owning views over a part of a bit-array — bit-slices. |
| Sub-vectors | Methods to clone a piece of a bit-array as a new bit-vector. |
| Riffling | Methods to create vectors that copy a bit-array with interleaved zeros. |
| Set/Unset Indices | Methods to find the indices of set & unset bits in a bit-array. |
| Iterators | Methods to create various iterators over a bit-array. |
| Stringification | Methods to create string representations of a bit-array. |
| Bit Shifts | Methods to shift the bits in a bit-array left or right. |
| Bitwise Operations | Methods to combine any bit-store and a bit-array using logical operations. |
| Arithmetic Operators | Methods to add or subtract any bit-store and a bit-array. |
| Other Functions | Dot products, convolutions, etc. for bit-stores with bit-arrays. |
§Trait Requirements
To implement the BitStore trait, the type defines the following seven methods:
| Method | Description |
|---|---|
BitArray::len | Returns the number of bits in the bit-array — the generic parameter N. |
BitArray::store | Provides read-only access to the first word holding bits in the bit-array. |
BitArray::store_mut | Provides read-write access to the first word holding bits in the bit-array. |
BitArray::offset | Returns the offset in bits from start of word(0) to the bit-array’s first element. |
BitArray::words | This is always Word::words_needed(self.len()) but cached for efficiency. |
BitArray::word | Returns a “word” from the bit-array. |
BitArray::set_word | Sets the value of a “word” in the bit-array to a passed value. |
These methods are trivial to implement for bit-arrays.
The one place where care is needed is in the BitArray::set_word method, which must ensure that any bits beyond the size of the bit-array remain set to zero.
§Constructors
The BitArray type provides several constructors to create bit-arrays with specific properties and fills:
| Method Name | Description |
|---|---|
BitArray::new | Returns a bit-array that has N zero elements. |
BitArray::zeros | Returns a bit-array where all the elements are 0. |
BitArray::ones | Returns a bit-array where all the elements are 1. |
BitArray::constant | Returns a bit-array where all the elements are whatever is passed as a value. |
BitArray::unit | Returns a bit-array where all the elements are zero except for a single 1. |
BitArray::alternating | Returns a bit-array where all the elements follow the pattern 101010... |
BitArray::from_word | Returns a bit-array filled with bits copied from a Word value. |
BitArray::from_fn | Returns a bit-array filled with bits set by calling a function for each index. |
BitArray::random | Returns a bit-array filled by flipping a fair coin seeded from entropy. |
BitArray::random_seeded | Returns a bit-array with a reproducible fair random fill. |
BitArray::random_biased | Returns a random bit-array where you set the probability of bits being 1. |
BitArray::random_biased_seeded | Returns a random bit-array where you set the probability of bits being 1 and the RNG’s seed. |
Note: We have implemented the Default trait for BitArray to return a zero-sized bit-vector.
§Bit Access (Inherited)
The following methods provide access to individual bit elements in the bit-array.
| Method | Description |
|---|---|
BitStore::get | Returns the value of a single bit element as a read-only boolean. |
BitStore::first | Returns the value of the first element in the bit-array. |
BitStore::last | Returns the value of the last element in the bit-array. |
BitStore::set | Sets a bit to the given boolean value. |
BitStore::flip | Flips the value of the bit element at a given index. |
BitStore::swap | Swaps the values of bit elements at locations i and j. |
§Queries (Inherited)
The following methods let you query the overall state of a bit-array.
| Method | Description |
|---|---|
BitStore::is_empty | Returns true if the bit-array is empty |
BitStore::any | Returns true if any bit in the bit-array is set. |
BitStore::all | Returns true if every bit in the bit-array is set. |
BitStore::none | Returns true if no bit in the bit-array is set. |
BitStore::count_ones | Returns the number of set bits in the bit-array. |
BitStore::count_zeros | Returns the number of unset bits in the bit-array. |
BitStore::leading_zeros | Returns the number of leading unset bits in the bit-array. |
BitStore::trailing_zeros | Returns the number of trailing unset bits in the bit-array. |
§Mutators (Inherited)
The following methods let you mutate the entire bit-array in a single call.
| Method | Description |
|---|---|
BitStore::set_all | Sets all the bits in the bit-array to the passed value. |
BitStore::flip_all | Flips the values of all the bits in the bit-array. |
BitStore::flipped | Returns a new bit-array that is a copy of the bit-vector with all the bits flipped. |
§Copies and Fills (Inherited)
The following methods let you populate the entire bit-array from multiple sources in a single call.
| Method | Description |
|---|---|
BitStore::copy_unsigned | Copies bit values from any unsigned value to this bit-array. |
BitStore::copy_store | Copies bit values from any source bit-store to this bit-array. |
BitStore::copy_fn | Copies bit values from a function that returns a boolean for an index. |
BitStore::fill_random_biased_seeded | Very general method to fill the bit-array with random 0’s and 1’s. |
BitStore::fill_random_biased | Fill the bit-array with random 0’s and 1’s, where the RNG itself is randomly seeded. |
BitStore::fill_random | Fill the bit-array with random 0’s and 1’s from flips of a fair coin. |
§Slices (Inherited)
The following methods let you create a BitSlice, which is a non-owning view of some contiguous subset of bits in the bit-array.
| Method | Description |
|---|---|
BitStore::slice | Returns a BitSlice encompassing the bits in a half-open range. |
BitStore::slice_mut | Returns a mutable BitSlice encompassing the bits in a half-open range. |
§Sub-vectors (Inherited)
The following methods create or fill independent bit-vectors with copies of some contiguous subset of the bits in the bit-array.
| Method | Description |
|---|---|
BitStore::sub | Returns a new BitVector encompassing the bits in a half-open range. |
BitStore::split_at_into | Fills two bit-vectors with the bits in the ranges [0, at) and [at, len()). |
BitStore::split_at | Returns two new two bit-vectors with the bits in the ranges [0, at) and [at, len()). |
§Riffling (Inherited)
We have methods that can interleave (riffle) the bits in a bit-array with zeros.
| Method | Description |
|---|---|
BitStore::riffled_into | Fills a pre-existing bit-vector with the result of riffling this bit-array. |
BitStore::riffled | Returns a new bit-vector that is this bit-array with its bits interleaved with zeros. |
§Set and Unset Bit Indices (Inherited)
The following methods find the indices of set or unset bits in the bit-array.
| Method | Description |
|---|---|
BitStore::first_set | Returns the index of the first set bit in the bit-array. |
BitStore::last_set | Returns the index of the last set bit in the bit-array. |
BitStore::next_set | Returns the index of the next set bit in the bit-array after the passed index. |
BitStore::previous_set | Returns the index of the previous set bit in the bit-array before the passed index. |
BitStore::first_unset | Returns the index of the first unset bit in the bit-array. |
BitStore::last_unset | Returns the index of the last unset bit in the bit-array. |
BitStore::next_unset | Returns the index of the next unset bit in the bit-array after the passed index. |
BitStore::previous_unset | Returns the index of the previous unset bit in the bit-array before the passed index. |
§Iterators (Inherited)
The following methods create iterators for traversing the bits or underlying words in the bit-array:
| Method | Description |
|---|---|
BitStore::bits | Returns a Bits iterator over the bits in the bit-array. |
BitStore::set_bits | Returns a SetBits iterator to view the indices of all the set bits. |
BitStore::unset_bits | Returns a UnsetBits iterator to view the indices of all the unset bits. |
BitStore::store_words | Returns a Words iterator to view the “words” underlying the bit-array. |
BitStore::to_words | Returns a copy of the “words” underlying the bit-array. |
§Stringification (Inherited)
The following functions returns a string representation of a bit-array. The string can be in the obvious binary format or a more compact hex format.
| Method | Description |
|---|---|
BitStore::to_custom_binary_string | Returns a binary string representation for a bit-array with various customisation parameters. |
BitStore::to_binary_string | Returns the simplest binary string representation for a bit-array. |
BitStore::to_pretty_string | Returns a “pretty” binary string representation for a bit-array. |
BitStore::to_hex_string | Returns a compact hex string representation for a bit-array. |
std::string::ToString::to_string | Delegates to BitStore::to_binary_string. |
BitStore::describe | Returns a multi-line string describing the bit-array in some detail. |
§Bit Shifts (Inherited)
We have methods to shift the bits in a bit-vector left or right.
| Methods | Description |
|---|---|
BitStore::left_shift | Left shifts in-place. |
BitStore::right_shift | Right shifts in-place. |
BitStore::left_shifted | Copies the bit-array to a new bit-vector and left shifts that vector. |
BitStore::right_shifted | Copies the bit-array to a new bit-vector and right shifts that vector. |
Note: We have also implemented the std::ops::ShlAssign, std::ops::ShrAssign, std::ops::Shl, and std::ops::Shr foreign traits to provide operator overloads for the shift operations. Those implementations forward to the associated methods above.
§Bitwise Operations (Inherited)
We have methods that combine a bit-array with any other bit-store using the logical operations XOR, AND, and OR.
| Method | Description |
|---|---|
BitStore::xor_eq | In-place XOR operation of equal-sized bit-stores: lhs = lhs ^ rhs. |
BitStore::and_eq | In-place AND operation of equal-sized bit-stores: lhs = lhs & rhs. |
BitStore::or_eq | In-place OR operation of equal-sized bit-stores: lhs = lhs | rhs. |
BitStore::xor | Returns the XOR of this store with another equal-sized store as a new bit-vector. |
BitStore::and | Returns the AND of this store with another equal-sized store as a new bit-vector. |
BitStore::or | Returns the OR of this store with another equal-sized store as a new bit-vector. |
Note: We have also implemented the std::ops::BitXorAssign, std::ops::BitAndAssign, std::ops::BitOrAssign, std::ops::BitXor, std::ops::BitAnd, and std::ops::BitOr foreign traits to provide operator overloads for the bit-wise operations. Those implementations forward to the associated methods above.
§Arithmetic Operations (Inherited)
In GF(2), the arithmetic operators + and - are both the XOR operator.
| Method | Description |
|---|---|
BitStore::plus_eq | Adds the passed (equal-sized) rhs bit-store to this bit-vector. |
BitStore::minus_eq | Subtracts the passed (equal-sized) rhs bit-store from this bit-vector. |
BitStore::plus | Adds two equal-sized bit-stores and returns the result as a bit-vector. |
BitStore::minus | Subtracts two equal-sized bit-stores and returns the result as a bit-vector. |
Note: We have also implemented the std::ops::AddAssign, std::ops::SubAssign, std::ops::Add, and std::ops::Sub foreign traits to provide operator overloads for the arithmetic operations. Those implementations forward to the associated methods above.
§Other Inherited Functions
| Method | Description |
|---|---|
BitStore::dot | Returns the dot product of two equal-sized bit-stores as a boolean. |
BitStore::convolved_with | Returns the convolution of two bit-stores as a new bit-vector. |
§Foreign Traits for Individual Bit-Arrays
We have implemented several foreign traits from the standard library for bit-vectors.
| Trait Name | Description |
|---|---|
Default | Forwarded to BitArray::new. |
std::ops::Index | Forwarded to BitStore::get. |
std::ops::Not | Forwarded to BitStore::flipped. |
std::fmt::Display | Forwarded to BitStore::to_binary_string. |
std::fmt::Binary | Forwarded to BitStore::to_binary_string. |
std::fmt::UpperHex | Forwarded to BitStore::to_hex_string. |
std::fmt::LowerHex | Forwarded to BitStore::to_hex_string. |
std::ops::ShlAssign | Forwarded to BitStore::left_shift. |
std::ops::ShrAssign | Forwarded to BitStore::right_shift. |
std::ops::Shl | Forwarded to BitStore::left_shifted. |
std::ops::Shr | Forwarded to BitStore::right_shifted. |
The std::ops::Not trait is implemented for bit-arrays by value and by reference.
§Foreign Traits for Pairwise Bit-Array Operations with Other Bit-Stores
We have implemented several foreign traits from the standard library for bit-vectors interacting with other bit-stores.
| Trait Name | Description |
|---|---|
std::ops::BitXorAssign | Forwarded to BitStore::xor_eq |
std::ops::BitAndAssign | Forwarded to BitStore::and_eq |
std::ops::BitOrAssign | Forwarded to BitStore::or_eq |
std::ops::AddAssign | Forwarded to BitStore::plus_eq |
std::ops::SubAssign | Forwarded to BitStore::minus_eq |
std::ops::BitXor | Forwarded to BitStore::xor |
std::ops::BitAnd | Forwarded to BitStore::and |
std::ops::BitOr | Forwarded to BitStore::or |
std::ops::Add | Forwarded to BitStore::plus |
std::ops::Sub | Forwarded to BitStore::minus |
std::ops::Mul | Forwarded to BitStore::dot |
Implementations§
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitArray<N, Word, WORDS>
Constructors for bit-arrays.
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitArray<N, Word, WORDS>
Constructors for bit-arrays.
Sourcepub fn new() -> Self
pub fn new() -> Self
The default constructor constructs a bit-array with N elements that are all zeros.
§Examples
use gf2::*;
let v: BitArray<10, u8> = BitArray::new();
assert_eq!(v.to_string(), "0000000000");Sourcepub fn from_word(word: Word) -> Self
pub fn from_word(word: Word) -> Self
Constructs a bit-array with N elements by repeatedly copying the bits from a single Word instance.
The final copy of word may be truncated and padded with zeros (unused bits are always set to zero in this
crate).
§Examples
use gf2::*;
let v: BitArray<10, u8> = BitArray::from_word(0b01010101);
assert_eq!(v.to_string(), "1010101010");Sourcepub fn zeros() -> Self
pub fn zeros() -> Self
Constructs a bit-array with ``Nelements, all initialized to0`.
§Examples
use gf2::*;
let v: BitArray<10, u8> = BitArray::zeros();
assert_eq!(v.to_string(), "0000000000");Sourcepub fn ones() -> Self
pub fn ones() -> Self
Constructs a bit-array with N elements, all initialized to 1.
§Examples
use gf2::*;
let v: BitArray<10, u8> = BitArray::ones();
assert_eq!(v.to_string(), "1111111111");Sourcepub fn constant(val: bool) -> Self
pub fn constant(val: bool) -> Self
Returns a bit-array with N elements, all initialized to the boolean value val.
§Examples
use gf2::*;
let v: BitArray<10> = BitArray::constant(true);
assert_eq!(v.to_string(), "1111111111");
let v: BitArray<10> = BitArray::constant(false);
assert_eq!(v.to_string(), "0000000000");Sourcepub fn alternating() -> Self
pub fn alternating() -> Self
Constructs a bit-array with N elements, where the bits alternate between 1 and 0.
The pattern starts with a 1 so e.g. 1010101010101.
§Examples
use gf2::*;
let v: BitArray<10> = BitArray::alternating();
assert_eq!(v.to_string(), "1010101010");Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitArray<N, Word, WORDS>
Constructors that set the elements of a bit-array randomly.
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitArray<N, Word, WORDS>
Constructors that set the elements of a bit-array randomly.
Sourcepub fn random() -> Self
pub fn random() -> Self
Constructs a random bit-array with N elements where each bit is set/unset with probability 50/50.
The random number generator is seeded on first use with a scrambled version of the current time so you get different outputs for each run.
See the random_seeded method for a way to get reproducible randomly filled bit-arrays.
§Examples
use gf2::*;
let v: BitArray<10> = BitArray::random();
assert_eq!(v.len(), 10);Sourcepub fn random_seeded(seed: u64) -> Self
pub fn random_seeded(seed: u64) -> Self
Constructs a random bit-array with N elements where each bit is set/unset with probability 50/50.
For reproducibility, the random number generator used here is seeded with the specified seed.
§Note
- The generator is reset to the previous seed after the bit-array is constructed.
- A seed of
0is taken to seed the generator from a scrambled version of the current time.
§Examples
use gf2::*;
let v1: BitArray<1000, u8> = BitArray::random_seeded(42);
let v2: BitArray<1000, u8> = BitArray::random_seeded(42);
assert_eq!(v1, v2);Sourcepub fn random_biased(p: f64) -> Self
pub fn random_biased(p: f64) -> Self
Constructs a random bit-array with N elements where each bit is set with probability p.
The random number generator is seeded on first use with a scrambled version of the current time.
§Note
Probability p should be in the range [0, 1]. If p is outside this range, the function will return a
bit-array with all elements set or unset as appropriate.
§Examples
use gf2::*;
let v: BitArray<10> = BitArray::random_biased(0.578);
assert_eq!(v.len(), 10);Sourcepub fn random_biased_seeded(p: f64, seed: u64) -> Self
pub fn random_biased_seeded(p: f64, seed: u64) -> Self
Constructs a random bit-array with N elements where each bit is set with probability p and the RNG is
§Note
Probability p should be in the range [0, 1]. If p is outside this range, the function will return a
bit-array with all elements set or unset as appropriate.
§Examples
use gf2::*;
let v: BitArray<10> = BitArray::random_biased_seeded(1.2, 42); // All bits set since p > 1
assert_eq!(v.count_ones(), 10);
let u: BitArray<100> = BitArray::random_biased_seeded(0.85, 42); // Using same seed for u and v.
let v: BitArray<100> = BitArray::random_biased_seeded(0.85, 42);
assert_eq!(u, v);Trait Implementations§
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for &BitVector<Word>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for BitVector<Word>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitVector<Word>> for &BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitVector<Word>> for BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for &BitVector<Word>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for BitVector<Word>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitVector<Word>> for &BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitVector<Word>> for BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Add for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Add for BitArray<N, Word, WORDS>
In GF(2), addition is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
§Note
Addition in GF(2) is the same as the XOR operation.
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 += &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn add_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn add_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
+= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Note
Addition in GF(2) is the same as the XOR operation.
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 += &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn add_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn add_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
+= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>
§Note
Addition in GF(2) is the same as the XOR operation.
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 += &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn add_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn add_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
+= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Note
Addition in GF(2) is the same as the XOR operation.
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 += &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn add_assign(&mut self, rhs: &BitSlice<'a, Word>)
fn add_assign(&mut self, rhs: &BitSlice<'a, Word>)
+= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>
§Note
Addition in GF(2) is the same as the XOR operation.
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 += &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn add_assign(&mut self, rhs: &BitVector<Word>)
fn add_assign(&mut self, rhs: &BitVector<Word>)
+= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Addition in GF(2) is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 += gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn add_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn add_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
+= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Addition in GF(2) is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 += gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn add_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn add_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
+= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Addition in GF(2) is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 += gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn add_assign(&mut self, rhs: BitSlice<'a, Word>)
fn add_assign(&mut self, rhs: BitSlice<'a, Word>)
+= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Addition in GF(2) is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 += gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn add_assign(&mut self, rhs: BitVector<Word>)
fn add_assign(&mut self, rhs: BitVector<Word>)
+= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Addition in GF(2) is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 += gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn add_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn add_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
+= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> Binary for BitArray<N, Word, WORDS>
Returns a binary string representation of the bits in a BitArray.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Binary for BitArray<N, Word, WORDS>
Returns a binary string representation of the bits in a BitArray.
The output is a string of 0 and 1 characters without any spaces, commas, or other formatting.
§Note
- The output is in vector order, with the least significant bit printed first on the left.
- If the
alternate#flag is set, the output is prefixed with0b.
§Examples
use gf2::*;
let v: gf2::BitVector = gf2::BitVector::new();
assert_eq!(format!("{v:b}"), "");
let v: gf2::BitVector = gf2::BitVector::ones(4);
assert_eq!(format!("{v:b}"), "1111");
assert_eq!(format!("{v:#b}"), "0b1111");Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for &BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitVector<Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for &BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitVector<Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 &= &v2;
assert_eq!(v1.to_string(), "0000000000");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitand_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn bitand_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
&= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 &= &v2;
assert_eq!(v1.to_string(), "0000000000");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitand_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn bitand_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
&= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 &= &v2;
assert_eq!(v1.to_string(), "0000000000");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitand_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn bitand_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
&= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 &= &v2;
assert_eq!(v1.to_string(), "0000000000");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitand_assign(&mut self, rhs: &BitSlice<'a, Word>)
fn bitand_assign(&mut self, rhs: &BitSlice<'a, Word>)
&= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 &= &v2;
assert_eq!(v1.to_string(), "0000000000");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitand_assign(&mut self, rhs: &BitVector<Word>)
fn bitand_assign(&mut self, rhs: &BitVector<Word>)
&= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 &= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "0000000000");Source§fn bitand_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn bitand_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
&= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 &= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "0000000000");Source§fn bitand_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn bitand_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
&= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 &= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "0000000000");Source§fn bitand_assign(&mut self, rhs: BitSlice<'a, Word>)
fn bitand_assign(&mut self, rhs: BitSlice<'a, Word>)
&= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 &= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "0000000000");Source§fn bitand_assign(&mut self, rhs: BitVector<Word>)
fn bitand_assign(&mut self, rhs: BitVector<Word>)
&= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 &= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "0000000000");Source§fn bitand_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn bitand_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
&= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for &BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitVector<Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for &BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitVector<Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 |= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn bitor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
|= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 |= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn bitor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
|= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 |= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn bitor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
|= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 |= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitor_assign(&mut self, rhs: &BitSlice<'a, Word>)
fn bitor_assign(&mut self, rhs: &BitSlice<'a, Word>)
|= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 |= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitor_assign(&mut self, rhs: &BitVector<Word>)
fn bitor_assign(&mut self, rhs: &BitVector<Word>)
|= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 |= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn bitor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn bitor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
|= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 |= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn bitor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn bitor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
|= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 |= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn bitor_assign(&mut self, rhs: BitSlice<'a, Word>)
fn bitor_assign(&mut self, rhs: BitSlice<'a, Word>)
|= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 |= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn bitor_assign(&mut self, rhs: BitVector<Word>)
fn bitor_assign(&mut self, rhs: BitVector<Word>)
|= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 |= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn bitor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn bitor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
|= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitStore<Word> for BitArray<N, Word, WORDS>
Implement the BitStore trait for BitArray.
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitStore<Word> for BitArray<N, Word, WORDS>
Implement the BitStore trait for BitArray.
Source§fn len(&self) -> usize
fn len(&self) -> usize
Returns the number of bits in the BitArray.
§Examples
use gf2::*;
let v: BitArray<10, u8> = BitArray::new();
assert_eq!(v.len(), 10);Source§fn store(&self) -> &[Word]
fn store(&self) -> &[Word]
Returns a pointer to the real words underlying the BitArray as an Unsigned slice.
Source§fn store_mut(&mut self) -> &mut [Word]
fn store_mut(&mut self) -> &mut [Word]
Returns a pointer to the real words underlying the BitArray as an Unsigned mutable slice.
Source§fn offset(&self) -> u32
fn offset(&self) -> u32
Returns the offset (in bits) of the first bit element in the BitArray within the first Unsigned word.
This is always zero for a BitArray.
Source§fn set_word(&mut self, i: usize, word: Word)
fn set_word(&mut self, i: usize, word: Word)
Sets the Unsigned word at index i in the BitArray to word.
§Panics
In debug mode, panics if i is out of bounds for the BitArray.
§Note
It is careful to only set the bits that are within the vector (the last word may only be partially occupied).
§Examples
use gf2::*;
let mut v: BitArray<12, u8> = BitArray::zeros();
v.set_word(0, 0b1111_1111);
v.set_word(1, 0b1111_1111);
assert_eq!(v.to_string(), "111111111111");
assert_eq!(v.count_ones(), 12);Source§fn flip(&mut self, i: usize) -> &mut Self
fn flip(&mut self, i: usize) -> &mut Self
i and returns a reference to the store for chaining. Read moreSource§fn set_all(&mut self, v: bool) -> &mut Self
fn set_all(&mut self, v: bool) -> &mut Self
v and returns a reference to the store for chaining. Read moreSource§fn flip_all(&mut self) -> &mut Self
fn flip_all(&mut self) -> &mut Self
Source§fn flipped(&self) -> BitVector<Word>
fn flipped(&self) -> BitVector<Word>
Source§fn copy_unsigned<Src>(&mut self, src: Src) -> &mut Self
fn copy_unsigned<Src>(&mut self, src: Src) -> &mut Self
src value. Read moreSource§fn copy_unsigneds<Src, SrcIter>(&mut self, src_iter: SrcIter) -> &mut Selfwhere
Src: Unsigned + TryInto<Word>,
SrcIter: IntoIterator<Item = Src>,
<SrcIter as IntoIterator>::IntoIter: ExactSizeIterator,
fn copy_unsigneds<Src, SrcIter>(&mut self, src_iter: SrcIter) -> &mut Selfwhere
Src: Unsigned + TryInto<Word>,
SrcIter: IntoIterator<Item = Src>,
<SrcIter as IntoIterator>::IntoIter: ExactSizeIterator,
Source§fn copy_store<SrcWord, SrcStore>(&mut self, src: &SrcStore) -> &mut Self
fn copy_store<SrcWord, SrcStore>(&mut self, src: &SrcStore) -> &mut Self
src of the same length. Read moreSource§fn copy_fn(&mut self, f: impl Fn(usize) -> bool) -> &mut Self
fn copy_fn(&mut self, f: impl Fn(usize) -> bool) -> &mut Self
f for each bit index. Read moreSource§fn fill_random_biased_seeded(&mut self, p: f64, seed: u64) -> &mut Self
fn fill_random_biased_seeded(&mut self, p: f64, seed: u64) -> &mut Self
p, and the RNG is seeded to seed.
A seed of 0 indicates we should randomly seed the RNG. Read moreSource§fn fill_random_biased(&mut self, p: f64) -> &mut Self
fn fill_random_biased(&mut self, p: f64) -> &mut Self
p, and the RNG is seeded using the
system clock. Read moreSource§fn fill_random_seeded(&mut self, seed: u64) -> &mut Self
fn fill_random_seeded(&mut self, seed: u64) -> &mut Self
0.5, and the RNG is seeded to seed.
A seed of 0 indicates we should randomly seed the RNG. Read moreSource§fn fill_random(&mut self) -> &mut Self
fn fill_random(&mut self) -> &mut Self
0.5, and the RNG is seeded using the
clock. Read moreSource§fn count_ones(&self) -> usize
fn count_ones(&self) -> usize
Source§fn count_zeros(&self) -> usize
fn count_zeros(&self) -> usize
Source§fn leading_zeros(&self) -> usize
fn leading_zeros(&self) -> usize
Source§fn trailing_zeros(&self) -> usize
fn trailing_zeros(&self) -> usize
Source§fn first_set(&self) -> Option<usize>
fn first_set(&self) -> Option<usize>
None if no bits are set. Read moreSource§fn last_set(&self) -> Option<usize>
fn last_set(&self) -> Option<usize>
None if no bits are set. Read moreSource§fn next_set(&self, index: usize) -> Option<usize>
fn next_set(&self, index: usize) -> Option<usize>
index in the store or None if no more set bits exist. Read moreSource§fn previous_set(&self, index: usize) -> Option<usize>
fn previous_set(&self, index: usize) -> Option<usize>
index in the store or None if no previous set bits exist. Read moreSource§fn first_unset(&self) -> Option<usize>
fn first_unset(&self) -> Option<usize>
None if all bits are set. Read moreSource§fn last_unset(&self) -> Option<usize>
fn last_unset(&self) -> Option<usize>
None if all bits are set. Read moreSource§fn next_unset(&self, index: usize) -> Option<usize>
fn next_unset(&self, index: usize) -> Option<usize>
index in the store or None if no more set bits exist. Read moreSource§fn previous_unset(&self, index: usize) -> Option<usize>
fn previous_unset(&self, index: usize) -> Option<usize>
index in the store or None if no more set bits exist. Read moreSource§fn bits(&self) -> Bits<'_, Self, Word> ⓘ
fn bits(&self) -> Bits<'_, Self, Word> ⓘ
bool. Read moreSource§fn set_bits(&self) -> SetBits<'_, Self, Word> ⓘ
fn set_bits(&self) -> SetBits<'_, Self, Word> ⓘ
true. The associated type is usize. Read moreSource§fn unset_bits(&self) -> UnsetBits<'_, Self, Word> ⓘ
fn unset_bits(&self) -> UnsetBits<'_, Self, Word> ⓘ
false. The associated type is usize. Read moreSource§fn store_words(&self) -> Words<'_, Self, Word> ⓘ
fn store_words(&self) -> Words<'_, Self, Word> ⓘ
Source§fn to_words(&self) -> Vec<Word>
fn to_words(&self) -> Vec<Word>
Source§fn to_words_into(&self, dst: &mut Vec<Word>)
fn to_words_into(&self, dst: &mut Vec<Word>)
Source§fn start_and_end_for<R: RangeBounds<usize>>(&self, range: R) -> (usize, usize)
fn start_and_end_for<R: RangeBounds<usize>>(&self, range: R) -> (usize, usize)
start and end as a pair of usizes. Read moreSource§fn sub<R: RangeBounds<usize>>(&self, range: R) -> BitVector<Word>
fn sub<R: RangeBounds<usize>>(&self, range: R) -> BitVector<Word>
[begin, end) as a new bit-vector. Read moreSource§fn split_at_into(
&self,
at: usize,
left: &mut BitVector<Word>,
right: &mut BitVector<Word>,
)
fn split_at_into( &self, at: usize, left: &mut BitVector<Word>, right: &mut BitVector<Word>, )
Source§fn split_at(&self, at: usize) -> (BitVector<Word>, BitVector<Word>)
fn split_at(&self, at: usize) -> (BitVector<Word>, BitVector<Word>)
Source§fn riffled_into(&self, dst: &mut BitVector<Word>)
fn riffled_into(&self, dst: &mut BitVector<Word>)
dst with the bits in the original vector interleaved with
zeros. Read moreSource§fn riffled(&self) -> BitVector<Word>
fn riffled(&self) -> BitVector<Word>
Source§fn dot<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> bool
fn dot<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> bool
Source§fn convolved_with<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>
fn convolved_with<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>
Source§fn to_binary_string(&self) -> String
fn to_binary_string(&self) -> String
Source§fn to_pretty_string(&self) -> String
fn to_pretty_string(&self) -> String
Source§fn to_custom_binary_string(
&self,
separator: &str,
left: &str,
right: &str,
) -> String
fn to_custom_binary_string( &self, separator: &str, left: &str, right: &str, ) -> String
Source§fn to_hex_string(&self) -> String
fn to_hex_string(&self) -> String
Source§fn describe(&self) -> String
fn describe(&self) -> String
Source§fn left_shift(&mut self, shift: usize)
fn left_shift(&mut self, shift: usize)
shift places. Read moreSource§fn left_shifted(&self, shift: usize) -> BitVector<Word>
fn left_shifted(&self, shift: usize) -> BitVector<Word>
shift places. Read moreSource§fn right_shift(&mut self, shift: usize)
fn right_shift(&mut self, shift: usize)
shift places. Read moreSource§fn right_shifted(&self, shift: usize) -> BitVector<Word>
fn right_shifted(&self, shift: usize) -> BitVector<Word>
shift places. Read moreSource§fn xor_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)
fn xor_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)
Source§fn xor<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>
fn xor<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>
Source§fn and_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)
fn and_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)
Source§fn and<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>
fn and<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>
Source§fn or_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)
fn or_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)
Source§fn or<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>
fn or<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>
Source§fn plus_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)
fn plus_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)
Source§fn plus<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>
fn plus<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for &BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitVector<Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for &BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitVector<Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 ^= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitxor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn bitxor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
^= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 ^= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitxor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn bitxor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
^= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 ^= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitxor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn bitxor_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
^= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 ^= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitxor_assign(&mut self, rhs: &BitSlice<'a, Word>)
fn bitxor_assign(&mut self, rhs: &BitSlice<'a, Word>)
^= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 ^= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn bitxor_assign(&mut self, rhs: &BitVector<Word>)
fn bitxor_assign(&mut self, rhs: &BitVector<Word>)
^= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 ^= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn bitxor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn bitxor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
^= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 ^= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn bitxor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn bitxor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
^= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 ^= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn bitxor_assign(&mut self, rhs: BitSlice<'a, Word>)
fn bitxor_assign(&mut self, rhs: BitSlice<'a, Word>)
^= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 ^= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn bitxor_assign(&mut self, rhs: BitVector<Word>)
fn bitxor_assign(&mut self, rhs: BitVector<Word>)
^= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 ^= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn bitxor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn bitxor_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
^= operation. Read moreSource§impl<const N: usize, Word: Clone + Unsigned, const WORDS: usize> Clone for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Clone + Unsigned, const WORDS: usize> Clone for BitArray<N, Word, WORDS>
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Debug for BitArray<N, Word, WORDS>
Returns a binary string representation of the bits in a BitArray.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Debug for BitArray<N, Word, WORDS>
Returns a binary string representation of the bits in a BitArray.
The output is a string of 0 and 1 characters without any spaces, commas, or other formatting.
§Note
- The output is in vector order, with the least significant bit printed first on the left.
§Examples
use gf2::*;
let v: gf2::BitVector = gf2::BitVector::ones(10);
assert_eq!(format!("{v:?}"), "1111111111");Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Default for BitArray<N, Word, WORDS>
Implement the Default trait for a bit-array.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Default for BitArray<N, Word, WORDS>
Implement the Default trait for a bit-array.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Display for BitArray<N, Word, WORDS>
Returns a binary string representation of the bits in a BitArray.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Display for BitArray<N, Word, WORDS>
Returns a binary string representation of the bits in a BitArray.
The output is a string of 0 and 1 characters without any spaces, commas, or other formatting.
§Note
- The output is in vector order, with the least significant bit printed first on the left.
- If the
alternate#flag is set, the output is prefixed with0b.
§Examples
use gf2::*;
let v: gf2::BitVector = gf2::BitVector::new();
assert_eq!(format!("{v:b}"), "");
let v: gf2::BitVector = gf2::BitVector::ones(4);
assert_eq!(format!("{v:b}"), "1111");
assert_eq!(format!("{v:#b}"), "0b1111");Source§impl<const N: usize, Word: Hash + Unsigned, const WORDS: usize> Hash for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Hash + Unsigned, const WORDS: usize> Hash for BitArray<N, Word, WORDS>
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Index<usize> for BitArray<N, Word, WORDS>
std::ops::Index<usize> for a BitArray.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Index<usize> for BitArray<N, Word, WORDS>
std::ops::Index<usize> for a BitArray.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> LowerHex for BitArray<N, Word, WORDS>
Returns a lower hex string representation of the bits in a BitArray.
impl<const N: usize, Word: Unsigned, const WORDS: usize> LowerHex for BitArray<N, Word, WORDS>
Returns a lower hex string representation of the bits in a BitArray.
The output is a string of lower case hex characters without any spaces, commas, or other formatting.
The string may have a two character suffix of the form “.base” where base is one of 2, 4 or 8.
All hex characters encode 4 bits: “0x0” -> 0b0000, “0x1” -> 0b0001, …, “0xf” -> 0b1111.
The three possible “.base” suffixes allow for bit-vectors whose length is not a multiple of 4.
Empty bit-vectors are represented as the empty string.
0x1is the hex representation of the bit-vector0001=> length 4.0x1.8is the hex representation of the bit-vector001=> length 3.0x1.4is the hex representation of the bit-vector01=> length 2.0x1.2is the hex representation of the bit-vector1=> length 1.
§Note
- The output is in vector-order with the least significant bits printed first on the left.
- If the
alternate#flag is set, the output is prefixed with0x.
§Examples
use gf2::*;
let v: gf2::BitVector = gf2::BitVector::new();
assert_eq!(format!("{v:x}"), "");
let v: gf2::BitVector = gf2::BitVector::ones(4);
assert_eq!(format!("{v:x}"), "f");
assert_eq!(format!("{v:#x}"), "0xf");Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitMatrix<Word>
BitMatrix, BitArray multiplication where neither operand is consumed by the operation.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitMatrix<Word>
BitMatrix, BitArray multiplication where neither operand is consumed by the operation.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitMatrix<Word>
BitMatrix, BitArray multiplication where the matrix is consumed by the operation.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitMatrix<Word>
BitMatrix, BitArray multiplication where the matrix is consumed by the operation.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitMatrix<Word>> for &BitArray<N, Word, WORDS>
$Rhs, BitMatrix multiplication where neither operand is consumed by the operation.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitMatrix<Word>> for &BitArray<N, Word, WORDS>
$Rhs, BitMatrix multiplication where neither operand is consumed by the operation.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitMatrix<Word>> for BitArray<N, Word, WORDS>
$Rhs, BitMatrix multiplication where the vector is consumed by the operation.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitMatrix<Word>> for BitArray<N, Word, WORDS>
$Rhs, BitMatrix multiplication where the vector is consumed by the operation.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitVector<Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitMatrix<Word>
BitMatrix, BitArray multiplication where the vector is consumed by the operation.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitMatrix<Word>
BitMatrix, BitArray multiplication where the vector is consumed by the operation.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for BitMatrix<Word>
BitMatrix, BitArray multiplication where both operands are consumed by the operation.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for BitMatrix<Word>
BitMatrix, BitArray multiplication where both operands are consumed by the operation.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitMatrix<Word>> for &BitArray<N, Word, WORDS>
$Rhs, BitMatrix multiplication where the matrix is consumed by the operation.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitMatrix<Word>> for &BitArray<N, Word, WORDS>
$Rhs, BitMatrix multiplication where the matrix is consumed by the operation.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitMatrix<Word>> for BitArray<N, Word, WORDS>
$Rhs, BitMatrix multiplication where both operands are consumed by the operation.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitMatrix<Word>> for BitArray<N, Word, WORDS>
$Rhs, BitMatrix multiplication where both operands are consumed by the operation.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitVector<Word>> for &BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Not for &BitArray<N, Word, WORDS>
Flips all the bits in a BitArray reference, returning a new bit-vector. Leaves the left-hand side unchanged.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Not for &BitArray<N, Word, WORDS>
Flips all the bits in a BitArray reference, returning a new bit-vector. Leaves the left-hand side unchanged.
§Examples
use gf2::*;
let u: gf2::BitVector = gf2::BitVector::ones(3);
let v = !&u;
assert_eq!(u.to_binary_string(), "111");
assert_eq!(v.to_binary_string(), "000");Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Not for BitArray<N, Word, WORDS>
Flips all the bits in a BitArray, returning a new bit-vector. Consumes the left-hand side.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Not for BitArray<N, Word, WORDS>
Flips all the bits in a BitArray, returning a new bit-vector. Consumes the left-hand side.
§Examples
use gf2::*;
let u: gf2::BitVector = gf2::BitVector::ones(3);
let v = !u;
assert_eq!(v.to_binary_string(), "000");Source§impl<const N: usize, Word: Ord + Unsigned, const WORDS: usize> Ord for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Ord + Unsigned, const WORDS: usize> Ord for BitArray<N, Word, WORDS>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<const N: usize, Word: PartialEq + Unsigned, const WORDS: usize> PartialEq for BitArray<N, Word, WORDS>
impl<const N: usize, Word: PartialEq + Unsigned, const WORDS: usize> PartialEq for BitArray<N, Word, WORDS>
Source§impl<const N: usize, Word: PartialOrd + Unsigned, const WORDS: usize> PartialOrd for BitArray<N, Word, WORDS>
impl<const N: usize, Word: PartialOrd + Unsigned, const WORDS: usize> PartialOrd for BitArray<N, Word, WORDS>
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Shl<usize> for &BitArray<N, Word, WORDS>
Shifts a BitArray reference left, returning a new bit-vector. Leaves the left-hand side unchanged.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Shl<usize> for &BitArray<N, Word, WORDS>
Shifts a BitArray reference left, returning a new bit-vector. Leaves the left-hand side unchanged.
Shifting is in vector-order so if v = [v0,v1,v2,v3] then &v << 1 = [v1,v2,v3,0].
§Examples
use gf2::*;
let v1: gf2::BitVector = gf2::BitVector::ones(10);
let v2 = &v1 << 3;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "1111111000");
let s2 = v2.slice(0..7);
assert_eq!(s2.to_string(), "1111111");
let v3 = &s2 << 3;
assert_eq!(v3.to_string(), "1111000");
assert_eq!(s2.to_string(), "1111111");Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Shl<usize> for BitArray<N, Word, WORDS>
Shifts a BitArray left, returning a new bit-vector. Consumes the left-hand side.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Shl<usize> for BitArray<N, Word, WORDS>
Shifts a BitArray left, returning a new bit-vector. Consumes the left-hand side.
Shifting is in vector-order so if v = [v0,v1,v2,v3] then v << 1 = [v1,v2,v3,0].
§Examples
use gf2::*;
let v1: gf2::BitVector = gf2::BitVector::ones(10);
let v2 = v1 << 3;
assert_eq!(v2.to_string(), "1111111000");
let s2 = v2.slice(0..7);
assert_eq!(s2.to_string(), "1111111");
let v3 = s2 << 3;
assert_eq!(v3.to_string(), "1111000");Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> ShlAssign<usize> for BitArray<N, Word, WORDS>
Shifts a BitArray left by a given number of bits in-place.
impl<const N: usize, Word: Unsigned, const WORDS: usize> ShlAssign<usize> for BitArray<N, Word, WORDS>
Shifts a BitArray left by a given number of bits in-place.
Shifting is in vector-order so if v = [v0,v1,v2,v3] then v <<= 1 is [v1,v2,v3,0] with zeros added to the right.
§Note
- Left shifting in vector-order is the same as right shifting in bit-order.
- Only accessible bits are affected by the shift.
§Examples
use gf2::*;
let mut bv: gf2::BitVector = gf2::BitVector::ones(10);
bv <<= 3;
assert_eq!(bv.to_string(), "1111111000");Source§fn shl_assign(&mut self, shift: usize)
fn shl_assign(&mut self, shift: usize)
<<= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> Shr<usize> for &BitArray<N, Word, WORDS>
Shifts a BitArray reference right, returning a new bit-vector. Leaves the left-hand side unchanged.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Shr<usize> for &BitArray<N, Word, WORDS>
Shifts a BitArray reference right, returning a new bit-vector. Leaves the left-hand side unchanged.
Shifting is in vector-order so if v = [v0,v1,v2,v3] then &v >> 1 = [0,v0,v1,v2] with zeros added to the left.
§Note
- Right shifting in vector-order is the same as left shifting in bit-order.
- Only accessible bits in the argument are affected by the shift.
§Examples
use gf2::*;
let v1: gf2::BitVector = gf2::BitVector::ones(10);
let v2 = &v1 >> 3;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0001111111");
let s2 = v2.slice(0..7);
assert_eq!(s2.to_string(), "0001111");
let v3 = &s2 >> 3;
assert_eq!(v3.to_string(), "0000001");
assert_eq!(s2.to_string(), "0001111");Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Shr<usize> for BitArray<N, Word, WORDS>
Shifts a BitArray right, returning a new bit-vector. Consumes the left-hand side.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Shr<usize> for BitArray<N, Word, WORDS>
Shifts a BitArray right, returning a new bit-vector. Consumes the left-hand side.
Shifting is in vector-order so if v = [v0,v1,v2,v3] then v >> 1 = [0,v0,v1,v2] with zeros added to the left.
§Note
- Right shifting in vector-order is the same as left shifting in bit-order.
- Only accessible bits in the argument are affected by the shift.
§Examples
use gf2::*;
let v1: gf2::BitVector = gf2::BitVector::ones(10);
let v2 = v1 >> 3;
assert_eq!(v2.to_string(), "0001111111");
let s2 = v2.slice(0..7);
assert_eq!(s2.to_string(), "0001111");
let v3 = s2 >> 3;
assert_eq!(v3.to_string(), "0000001");Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> ShrAssign<usize> for BitArray<N, Word, WORDS>
Shifts a BitArray right by a given number of bits in-place.
impl<const N: usize, Word: Unsigned, const WORDS: usize> ShrAssign<usize> for BitArray<N, Word, WORDS>
Shifts a BitArray right by a given number of bits in-place.
Shifting is in vector-order so if v = [v0,v1,v2,v3] then v >>= 1 is [0,v0,v1,v2] with zeros added to the left.
§Note
- Right shifting in vector-order is the same as left shifting in bit-order.
- Only accessible bits are affected by the shift.
§Examples
use gf2::*;
let mut bv: gf2::BitVector = gf2::BitVector::ones(10);
bv >>= 3;
assert_eq!(bv.to_string(), "0001111111");Source§fn shr_assign(&mut self, shift: usize)
fn shr_assign(&mut self, shift: usize)
>>= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
Subtracts a [& BitArray] reference and a BitArray reference, returning a new bit-vector.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
Subtracts a [& BitArray] reference and a BitArray reference, returning a new bit-vector.
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
Subtracts a [& BitSlice] reference and a BitArray reference, returning a new bit-vector.
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
Subtracts a [& BitSlice] reference and a BitArray reference, returning a new bit-vector.
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for &BitVector<Word>
Subtracts a [& BitVector] reference and a BitArray reference, returning a new bit-vector.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for &BitVector<Word>
Subtracts a [& BitVector] reference and a BitArray reference, returning a new bit-vector.
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for BitVector<Word>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
Subtracts a [& BitArray] reference and a BitSlice reference, returning a new bit-vector.
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
Subtracts a [& BitArray] reference and a BitSlice reference, returning a new bit-vector.
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitVector<Word>> for &BitArray<N, Word, WORDS>
Subtracts a [& BitArray] reference and a BitVector reference, returning a new bit-vector.
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitVector<Word>> for &BitArray<N, Word, WORDS>
Subtracts a [& BitArray] reference and a BitVector reference, returning a new bit-vector.
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitVector<Word>> for BitArray<N, Word, WORDS>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for &BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for &BitVector<Word>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for BitVector<Word>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitVector<Word>> for &BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitVector<Word>> for &BitArray<N, Word, WORDS>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitVector<Word>> for BitArray<N, Word, WORDS>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub for BitArray<N, Word, WORDS>
In GF(2), subtraction is the same as bitwise XOR.
§Panics
This method panics if the lengths of the input operands do not match.
Source§impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Subtraction in GF(2) is the same as addition which is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 -= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn sub_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn sub_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
-= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Subtraction in GF(2) is the same as addition which is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 -= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn sub_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn sub_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
-= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Subtraction in GF(2) is the same as addition which is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 -= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn sub_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
fn sub_assign(&mut self, rhs: &BitArray<N, Word, WORDS>)
-= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Subtraction in GF(2) is the same as addition which is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 -= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn sub_assign(&mut self, rhs: &BitSlice<'a, Word>)
fn sub_assign(&mut self, rhs: &BitSlice<'a, Word>)
-= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Subtraction in GF(2) is the same as addition which is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
let v2: gf2::BitVector = gf2::BitVector::from_string("0101010101").unwrap();
v1 -= &v2;
assert_eq!(v1.to_string(), "1111111111");
assert_eq!(v2.to_string(), "0101010101");Source§fn sub_assign(&mut self, rhs: &BitVector<Word>)
fn sub_assign(&mut self, rhs: &BitVector<Word>)
-= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Subtraction in GF(2) is the same as addition which is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 -= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn sub_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn sub_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
-= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitArray<N, Word, WORDS>> for BitVector<Word>
impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitArray<N, Word, WORDS>> for BitVector<Word>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Subtraction in GF(2) is the same as addition which is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 -= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn sub_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn sub_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
-= operation. Read moreSource§impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Subtraction in GF(2) is the same as addition which is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 -= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn sub_assign(&mut self, rhs: BitSlice<'a, Word>)
fn sub_assign(&mut self, rhs: BitSlice<'a, Word>)
-= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitVector<Word>> for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitVector<Word>> for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Subtraction in GF(2) is the same as addition which is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 -= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn sub_assign(&mut self, rhs: BitVector<Word>)
fn sub_assign(&mut self, rhs: BitVector<Word>)
-= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign for BitArray<N, Word, WORDS>
impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign for BitArray<N, Word, WORDS>
§Panics
This method panics if the lengths of the input operands do not match.
§Note
Subtraction in GF(2) is the same as addition which is the same as the XOR operation.
§Examples
use gf2::*;
let mut v1: gf2::BitVector = gf2::BitVector::from_string("1010101010").unwrap();
v1 -= gf2::BitVector::from_string("0101010101").unwrap();
assert_eq!(v1.to_string(), "1111111111");Source§fn sub_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
fn sub_assign(&mut self, rhs: BitArray<N, Word, WORDS>)
-= operation. Read moreSource§impl<const N: usize, Word: Unsigned, const WORDS: usize> UpperHex for BitArray<N, Word, WORDS>
Returns an upper hex string representation of the bits in a BitArray.
impl<const N: usize, Word: Unsigned, const WORDS: usize> UpperHex for BitArray<N, Word, WORDS>
Returns an upper hex string representation of the bits in a BitArray.
The output is a string of upper case hex characters without any spaces, commas, or other formatting.
The string may have a two character suffix of the form “.base” where base is one of 2, 4 or 8.
All hex characters encode 4 bits: “0X0” -> 0b0000, “0X1” -> 0b0001, …, “0XF” -> 0b1111.
The three possible “.base” suffixes allow for bit-vectors whose length is not a multiple of 4.
Empty bit-vectors are represented as the empty string.
0X1is the hex representation of the bit-vector0001=> length 4.0X1.8is the hex representation of the bit-vector001=> length 3.0X1.4is the hex representation of the bit-vector01=> length 2.0X1.2is the hex representation of the bit-vector1=> length 1.
§Note
- The output is in vector-order with the least significant bits printed first on the left.
- If the
alternate#flag is set, the output is prefixed with0X.
§Examples
use gf2::*;
let v: gf2::BitVector = gf2::BitVector::new();
assert_eq!(format!("{v:X}"), "");
let v: gf2::BitVector = gf2::BitVector::ones(4);
assert_eq!(format!("{v:X}"), "F");
assert_eq!(format!("{v:#X}"), "0XF");