Skip to main content

BitArray

Struct BitArray 

Source
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:

CategoryDescription
Trait RequirementsMethods needed to implement the BitStore trait.
ConstructorsMethods 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 CategoryDescription
Bit AccessMethods to access individual bit elements in a bit-array.
QueriesMethods to query the overall state of a bit-array.
MutatorsMethods to mutate the overall state of a bit-array.
Copies & FillsMethods to fill a bit-array from various sources.
SlicesMethods to create non-owning views over a part of a bit-array — bit-slices.
Sub-vectorsMethods to clone a piece of a bit-array as a new bit-vector.
RifflingMethods to create vectors that copy a bit-array with interleaved zeros.
Set/Unset IndicesMethods to find the indices of set & unset bits in a bit-array.
IteratorsMethods to create various iterators over a bit-array.
StringificationMethods to create string representations of a bit-array.
Bit ShiftsMethods to shift the bits in a bit-array left or right.
Bitwise OperationsMethods to combine any bit-store and a bit-array using logical operations.
Arithmetic OperatorsMethods to add or subtract any bit-store and a bit-array.
Other FunctionsDot products, convolutions, etc. for bit-stores with bit-arrays.

§Trait Requirements

To implement the BitStore trait, the type defines the following seven methods:

MethodDescription
BitArray::lenReturns the number of bits in the bit-array — the generic parameter N.
BitArray::storeProvides read-only access to the first word holding bits in the bit-array.
BitArray::store_mutProvides read-write access to the first word holding bits in the bit-array.
BitArray::offsetReturns the offset in bits from start of word(0) to the bit-array’s first element.
BitArray::wordsThis is always Word::words_needed(self.len()) but cached for efficiency.
BitArray::wordReturns a “word” from the bit-array.
BitArray::set_wordSets 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 NameDescription
BitArray::newReturns a bit-array that has N zero elements.
BitArray::zerosReturns a bit-array where all the elements are 0.
BitArray::onesReturns a bit-array where all the elements are 1.
BitArray::constantReturns a bit-array where all the elements are whatever is passed as a value.
BitArray::unitReturns a bit-array where all the elements are zero except for a single 1.
BitArray::alternatingReturns a bit-array where all the elements follow the pattern 101010...
BitArray::from_wordReturns a bit-array filled with bits copied from a Word value.
BitArray::from_fnReturns a bit-array filled with bits set by calling a function for each index.
BitArray::randomReturns a bit-array filled by flipping a fair coin seeded from entropy.
BitArray::random_seededReturns 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_seededReturns 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.

MethodDescription
BitStore::getReturns the value of a single bit element as a read-only boolean.
BitStore::firstReturns the value of the first element in the bit-array.
BitStore::lastReturns the value of the last element in the bit-array.
BitStore::setSets a bit to the given boolean value.
BitStore::flipFlips the value of the bit element at a given index.
BitStore::swapSwaps 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.

MethodDescription
BitStore::is_emptyReturns true if the bit-array is empty
BitStore::anyReturns true if any bit in the bit-array is set.
BitStore::allReturns true if every bit in the bit-array is set.
BitStore::noneReturns true if no bit in the bit-array is set.
BitStore::count_onesReturns the number of set bits in the bit-array.
BitStore::count_zerosReturns the number of unset bits in the bit-array.
BitStore::leading_zerosReturns the number of leading unset bits in the bit-array.
BitStore::trailing_zerosReturns 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.

MethodDescription
BitStore::set_allSets all the bits in the bit-array to the passed value.
BitStore::flip_allFlips the values of all the bits in the bit-array.
BitStore::flippedReturns 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.

MethodDescription
BitStore::copy_unsignedCopies bit values from any unsigned value to this bit-array.
BitStore::copy_storeCopies bit values from any source bit-store to this bit-array.
BitStore::copy_fnCopies bit values from a function that returns a boolean for an index.
BitStore::fill_random_biased_seededVery general method to fill the bit-array with random 0’s and 1’s.
BitStore::fill_random_biasedFill the bit-array with random 0’s and 1’s, where the RNG itself is randomly seeded.
BitStore::fill_randomFill 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.

MethodDescription
BitStore::sliceReturns a BitSlice encompassing the bits in a half-open range.
BitStore::slice_mutReturns 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.

MethodDescription
BitStore::subReturns a new BitVector encompassing the bits in a half-open range.
BitStore::split_at_intoFills two bit-vectors with the bits in the ranges [0, at) and [at, len()).
BitStore::split_atReturns 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.

MethodDescription
BitStore::riffled_intoFills a pre-existing bit-vector with the result of riffling this bit-array.
BitStore::riffledReturns 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.

MethodDescription
BitStore::first_setReturns the index of the first set bit in the bit-array.
BitStore::last_setReturns the index of the last set bit in the bit-array.
BitStore::next_setReturns the index of the next set bit in the bit-array after the passed index.
BitStore::previous_setReturns the index of the previous set bit in the bit-array before the passed index.
BitStore::first_unsetReturns the index of the first unset bit in the bit-array.
BitStore::last_unsetReturns the index of the last unset bit in the bit-array.
BitStore::next_unsetReturns the index of the next unset bit in the bit-array after the passed index.
BitStore::previous_unsetReturns 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:

MethodDescription
BitStore::bitsReturns a Bits iterator over the bits in the bit-array.
BitStore::set_bitsReturns a SetBits iterator to view the indices of all the set bits.
BitStore::unset_bitsReturns a UnsetBits iterator to view the indices of all the unset bits.
BitStore::store_wordsReturns a Words iterator to view the “words” underlying the bit-array.
BitStore::to_wordsReturns 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.

MethodDescription
BitStore::to_custom_binary_stringReturns a binary string representation for a bit-array with various customisation parameters.
BitStore::to_binary_stringReturns the simplest binary string representation for a bit-array.
BitStore::to_pretty_stringReturns a “pretty” binary string representation for a bit-array.
BitStore::to_hex_stringReturns a compact hex string representation for a bit-array.
std::string::ToString::to_stringDelegates to BitStore::to_binary_string.
BitStore::describeReturns 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.

MethodsDescription
BitStore::left_shiftLeft shifts in-place.
BitStore::right_shiftRight shifts in-place.
BitStore::left_shiftedCopies the bit-array to a new bit-vector and left shifts that vector.
BitStore::right_shiftedCopies 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.

MethodDescription
BitStore::xor_eqIn-place XOR operation of equal-sized bit-stores: lhs = lhs ^ rhs.
BitStore::and_eqIn-place AND operation of equal-sized bit-stores: lhs = lhs & rhs.
BitStore::or_eqIn-place OR operation of equal-sized bit-stores: lhs = lhs | rhs.
BitStore::xorReturns the XOR of this store with another equal-sized store as a new bit-vector.
BitStore::andReturns the AND of this store with another equal-sized store as a new bit-vector.
BitStore::orReturns 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.

MethodDescription
BitStore::plus_eqAdds the passed (equal-sized) rhs bit-store to this bit-vector.
BitStore::minus_eqSubtracts the passed (equal-sized) rhs bit-store from this bit-vector.
BitStore::plusAdds two equal-sized bit-stores and returns the result as a bit-vector.
BitStore::minusSubtracts 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

MethodDescription
BitStore::dotReturns the dot product of two equal-sized bit-stores as a boolean.
BitStore::convolved_withReturns 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.

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.

Implementations§

Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitArray<N, Word, WORDS>

Constructors for bit-arrays.

Source

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");
Source

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");
Source

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");
Source

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");
Source

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");
Source

pub fn unit(i: usize) -> Self

Constructs the unit bit-array where only element i of N elements is set to 1.

§Panics

Panics if i is greater than or equal to N.

§Examples
use gf2::*;
let v: BitArray<10> = BitArray::unit(5);
assert_eq!(v.to_string(), "0000010000");
Source

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

pub fn from_fn(f: impl Fn(usize) -> bool) -> Self

Constructs a bit-array with N elements by calling a function f for each bit index.

§Examples
use gf2::*;
let v: BitArray<10> = BitArray::from_fn(|i| i % 2 == 0);
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.

Source

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);
Source

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 0 is 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);
Source

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);
Source

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);
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitArray<N, Word, WORDS>

Vector-matrix multiplication for a BitArray

Source

pub fn dot_matrix(&self, rhs: &BitMatrix<Word>) -> BitVector<Word>

BitArray matrix multiplication as a new [BitVector`].

§Panics

Panics if the operands have incompatible dimensions.

§Examples
use gf2::*;
let v: BitVector = BitVector::ones(3);
let m: BitMatrix = BitMatrix::identity(3);
assert_eq!((&v * &m).to_string(), "111");

Trait Implementations§

Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>

Adds a BitArray reference and a BitArray reference, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>

Adds a BitSlice reference and a BitArray reference, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for &BitVector<Word>

Adds a BitVector reference and a BitArray reference, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

Adds a BitArray and a BitArray reference, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

Adds a BitSlice and a BitArray reference, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitArray<N, Word, WORDS>> for BitVector<Word>

Adds a BitVector and a BitArray reference, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>

Adds a BitArray reference and a BitSlice reference, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

Adds a BitArray and a BitSlice reference, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitVector<Word>> for &BitArray<N, Word, WORDS>

Adds a BitArray reference and a BitVector reference, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &BitVector<Word>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<&BitVector<Word>> for BitArray<N, Word, WORDS>

Adds a BitArray and a BitVector reference, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &BitVector<Word>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>

Adds a BitArray reference and a BitArray, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>

Adds a BitSlice reference and a BitArray, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for &BitVector<Word>

Adds a BitVector reference and a BitArray, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

Adds a BitSlice and a BitArray, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitArray<N, Word, WORDS>> for BitVector<Word>

Adds a BitVector and a BitArray, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>

Adds a BitArray reference and a BitSlice, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Add<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

Adds a BitArray and a BitSlice, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitVector<Word>> for &BitArray<N, Word, WORDS>

Adds a BitArray reference and a BitVector, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BitVector<Word>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add<BitVector<Word>> for BitArray<N, Word, WORDS>

Adds a BitArray and a BitVector, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BitVector<Word>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Add for BitArray<N, Word, WORDS>

Adds a BitArray and a BitArray, returning a new bit-vector.

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§

type Output = BitVector<Word>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

In-place addition of a BitArray with a BitArray reference.

§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>)

Performs the += operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

In-place addition of a BitSlice with a BitArray reference.

§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>)

Performs the += operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>

In-place addition of a BitVector with a BitArray reference.

§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>)

Performs the += operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

In-place addition of a BitArray with a BitSlice reference.

§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>)

Performs the += operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>

In-place addition of a BitArray with a BitVector reference.

§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>)

Performs the += operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

In-place addition of a BitSlice with a BitArray.

§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>)

Performs the += operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitArray<N, Word, WORDS>> for BitVector<Word>

In-place addition of a BitVector with a BitArray.

§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>)

Performs the += operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

In-place addition of a BitArray with a BitSlice.

§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>)

Performs the += operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign<BitVector<Word>> for BitArray<N, Word, WORDS>

In-place addition of a BitArray with a BitVector.

§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>)

Performs the += operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> AddAssign for BitArray<N, Word, WORDS>

In-place addition of a BitArray with a BitArray.

§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>)

Performs the += operation. Read more
Source§

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 with 0b.

§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§

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

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

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>

AND’s a BitArray reference and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>

AND’s a BitSlice reference and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for &BitVector<Word>

AND’s a BitVector reference and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

AND’s a BitArray and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

AND’s a BitSlice and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitArray<N, Word, WORDS>> for BitVector<Word>

AND’s a BitVector and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>

AND’s a BitArray reference and a BitSlice reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the & operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

AND’s a BitArray and a BitSlice reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitVector<Word>> for &BitArray<N, Word, WORDS>

AND’s a BitArray reference and a BitVector reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BitVector<Word>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<&BitVector<Word>> for BitArray<N, Word, WORDS>

AND’s a BitArray and a BitVector reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &BitVector<Word>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>

AND’s a BitArray reference and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>

AND’s a BitSlice reference and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for &BitVector<Word>

AND’s a BitVector reference and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

AND’s a BitSlice and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitArray<N, Word, WORDS>> for BitVector<Word>

AND’s a BitVector and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>

AND’s a BitArray reference and a BitSlice, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the & operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

AND’s a BitArray and a BitSlice, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitVector<Word>> for &BitArray<N, Word, WORDS>

AND’s a BitArray reference and a BitVector, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitVector<Word>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd<BitVector<Word>> for BitArray<N, Word, WORDS>

AND’s a BitArray and a BitVector, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitVector<Word>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAnd for BitArray<N, Word, WORDS>

AND’s a BitArray and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the & operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

In-place AND’s a BitArray with a BitArray reference.

§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>)

Performs the &= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

In-place AND’s a BitSlice with a BitArray reference.

§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>)

Performs the &= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>

In-place AND’s a BitVector with a BitArray reference.

§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>)

Performs the &= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

In-place AND’s a BitArray with a BitSlice reference.

§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>)

Performs the &= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>

In-place AND’s a BitArray with a BitVector reference.

§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>)

Performs the &= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

In-place AND’s a BitSlice with a BitArray.

§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>)

Performs the &= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitArray<N, Word, WORDS>> for BitVector<Word>

In-place AND’s a BitVector with a BitArray.

§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>)

Performs the &= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

In-place AND’s a BitArray with a BitSlice.

§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>)

Performs the &= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign<BitVector<Word>> for BitArray<N, Word, WORDS>

In-place AND’s a BitArray with a BitVector.

§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>)

Performs the &= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitAndAssign for BitArray<N, Word, WORDS>

In-place AND’s a BitArray with a BitArray.

§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>)

Performs the &= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>

OR’s a BitArray reference and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>

OR’s a BitSlice reference and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for &BitVector<Word>

OR’s a BitVector reference and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

OR’s a BitArray and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

OR’s a BitSlice and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitArray<N, Word, WORDS>> for BitVector<Word>

OR’s a BitVector and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>

OR’s a BitArray reference and a BitSlice reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the | operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

OR’s a BitArray and a BitSlice reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitVector<Word>> for &BitArray<N, Word, WORDS>

OR’s a BitArray reference and a BitVector reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BitVector<Word>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<&BitVector<Word>> for BitArray<N, Word, WORDS>

OR’s a BitArray and a BitVector reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &BitVector<Word>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>

OR’s a BitArray reference and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>

OR’s a BitSlice reference and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for &BitVector<Word>

OR’s a BitVector reference and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

OR’s a BitSlice and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitArray<N, Word, WORDS>> for BitVector<Word>

OR’s a BitVector and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>

OR’s a BitArray reference and a BitSlice, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the | operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

OR’s a BitArray and a BitSlice, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitVector<Word>> for &BitArray<N, Word, WORDS>

OR’s a BitArray reference and a BitVector, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitVector<Word>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr<BitVector<Word>> for BitArray<N, Word, WORDS>

OR’s a BitArray and a BitVector, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitVector<Word>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOr for BitArray<N, Word, WORDS>

OR’s a BitArray and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the | operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

In-place OR’s a BitArray with a BitArray reference.

§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>)

Performs the |= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

In-place OR’s a BitSlice with a BitArray reference.

§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>)

Performs the |= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>

In-place OR’s a BitVector with a BitArray reference.

§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>)

Performs the |= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

In-place OR’s a BitArray with a BitSlice reference.

§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>)

Performs the |= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>

In-place OR’s a BitArray with a BitVector reference.

§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>)

Performs the |= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

In-place OR’s a BitSlice with a BitArray.

§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>)

Performs the |= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitArray<N, Word, WORDS>> for BitVector<Word>

In-place OR’s a BitVector with a BitArray.

§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>)

Performs the |= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

In-place OR’s a BitArray with a BitSlice.

§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>)

Performs the |= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign<BitVector<Word>> for BitArray<N, Word, WORDS>

In-place OR’s a BitArray with a BitVector.

§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>)

Performs the |= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitOrAssign for BitArray<N, Word, WORDS>

In-place OR’s a BitArray with a BitArray.

§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>)

Performs the |= operation. Read more
Source§

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

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]

Returns a pointer to the real words underlying the BitArray as an Unsigned slice.

Source§

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

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 words(&self) -> usize

Returns the least number of Unsigned words needed to store the bits in the BitArray.

§Examples
use gf2::*;
let v: BitArray<6, u8> = BitArray::zeros();
assert_eq!(v.words(), 1);
let v: BitArray<10, u8> = BitArray::zeros();
assert_eq!(v.words(), 2);
Source§

fn word(&self, i: usize) -> Word

Returns the Unsigned word at index i from the BitArray’s underlying store of words.

§Panics

In debug mode, panics if i is out of bounds for the BitArray.

§Examples
use gf2::*;
let v: BitArray<10, u8> = BitArray::zeros();
assert_eq!(v.word(0), 0);
Source§

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 get(&self, i: usize) -> bool

Returns true if element i in the store is set to 1. Read more
Source§

fn first(&self) -> bool

Returns true if the first bit in the store is set. Read more
Source§

fn last(&self) -> bool

Returns true if the last bit in the store is set. Read more
Source§

fn set(&mut self, i: usize, val: bool) -> &mut Self

Sets the bit at index i to the boolean val and returns a reference to the store. Read more
Source§

fn flip(&mut self, i: usize) -> &mut Self

Flips the bit at index i and returns a reference to the store for chaining. Read more
Source§

fn swap(&mut self, i0: usize, i1: usize) -> &mut Self

Swaps the bits at indices i0 and i1 and returns a reference to the store for chaining. Read more
Source§

fn is_empty(&self) -> bool

Returns true if the store is empty. Read more
Source§

fn any(&self) -> bool

Returns true if at least one bit is set to 1 in the store. Read more
Source§

fn all(&self) -> bool

Returns true if all of the bits are set to 1 in the store. Read more
Source§

fn none(&self) -> bool

Returns true if none of the bits are set to 1 in the store. Read more
Source§

fn set_all(&mut self, v: bool) -> &mut Self

Sets all bits in the store to the boolean value v and returns a reference to the store for chaining. Read more
Source§

fn flip_all(&mut self) -> &mut Self

Flips all bits in the store and returns a reference to it for chaining. Read more
Source§

fn flipped(&self) -> BitVector<Word>

Returns a new bit-vector that is the result of flipping all the bits in this bit-store. Read more
Source§

fn copy_unsigned<Src>(&mut self, src: Src) -> &mut Self
where Src: Unsigned + TryInto<Word>,

Copies the bits from an unsigned src value. Read more
Source§

fn copy_unsigneds<Src, SrcIter>(&mut self, src_iter: SrcIter) -> &mut Self
where Src: Unsigned + TryInto<Word>, SrcIter: IntoIterator<Item = Src>, <SrcIter as IntoIterator>::IntoIter: ExactSizeIterator,

Copies the bits from an iterator of unsigned values. Read more
Source§

fn copy_store<SrcWord, SrcStore>(&mut self, src: &SrcStore) -> &mut Self
where SrcWord: Unsigned, SrcStore: BitStore<SrcWord>,

Fills this bit-store with the bits from any other bit-store src of the same length. Read more
Source§

fn copy_fn(&mut self, f: impl Fn(usize) -> bool) -> &mut Self

Fills a bit-store by calling a function f for each bit index. Read more
Source§

fn fill_random_biased_seeded(&mut self, p: f64, seed: u64) -> &mut Self

Fills the store with random bits where each bit is set with probability p, and the RNG is seeded to seed. A seed of 0 indicates we should randomly seed the RNG. Read more
Source§

fn fill_random_biased(&mut self, p: f64) -> &mut Self

Fills the store with random bits where each bit is set with probability p, and the RNG is seeded using the system clock. Read more
Source§

fn fill_random_seeded(&mut self, seed: u64) -> &mut Self

Fills the store with random bits where each bit is set with probability 0.5, and the RNG is seeded to seed. A seed of 0 indicates we should randomly seed the RNG. Read more
Source§

fn fill_random(&mut self) -> &mut Self

Fills the store with random bits where each bit is set with probability 0.5, and the RNG is seeded using the clock. Read more
Source§

fn count_ones(&self) -> usize

Returns the number of set bits in the store. Read more
Source§

fn count_zeros(&self) -> usize

Returns the number of unset bits in the store. Read more
Source§

fn leading_zeros(&self) -> usize

Returns the number of leading zeros in the store. Read more
Source§

fn trailing_zeros(&self) -> usize

Returns the number of trailing zeros in the store. Read more
Source§

fn first_set(&self) -> Option<usize>

Returns the index of the first set bit in the store or None if no bits are set. Read more
Source§

fn last_set(&self) -> Option<usize>

Returns the index of the last set bit in the store or None if no bits are set. Read more
Source§

fn next_set(&self, index: usize) -> Option<usize>

Returns the index of the next set bit after index in the store or None if no more set bits exist. Read more
Source§

fn previous_set(&self, index: usize) -> Option<usize>

Returns the index of the previous set bit before index in the store or None if no previous set bits exist. Read more
Source§

fn first_unset(&self) -> Option<usize>

Returns the index of the first unset bit in the store or None if all bits are set. Read more
Source§

fn last_unset(&self) -> Option<usize>

Returns the index of the last unset bit in the store or None if all bits are set. Read more
Source§

fn next_unset(&self, index: usize) -> Option<usize>

Returns the index of the next unset bit after index in the store or None if no more set bits exist. Read more
Source§

fn previous_unset(&self, index: usize) -> Option<usize>

Returns the index of the previous unset bit before index in the store or None if no more set bits exist. Read more
Source§

fn bits(&self) -> Bits<'_, Self, Word>

Returns an iterator over all the bits in the bit-store with the associated type bool. Read more
Source§

fn set_bits(&self) -> SetBits<'_, Self, Word>

Returns an iterator over all the bits in the bit-store that are set to true. The associated type is usize. Read more
Source§

fn unset_bits(&self) -> UnsetBits<'_, Self, Word>

Returns an iterator over all the bits in the bit-store that are set to false. The associated type is usize. Read more
Source§

fn store_words(&self) -> Words<'_, Self, Word>

Returns an iterator over the “words” in the bit-store with some Unsigned associated type. Read more
Source§

fn to_words(&self) -> Vec<Word>

Returns a copy of the words underlying this bit-store. Read more
Source§

fn to_words_into(&self, dst: &mut Vec<Word>)

Fills the provided destination vector with the words underlying this bit-store. Read more
Source§

fn slice<R: RangeBounds<usize>>(&self, range: R) -> BitSlice<'_, Word>

Returns a BitSlice of this store for the bits in the half-open range [range.start, range.end). Read more
Source§

fn slice_mut<R: RangeBounds<usize>>(&mut self, range: R) -> BitSlice<'_, Word>

Returns a mutable BitSlice of this store for the bits in the half-open range [range.start, range.end). Read more
Source§

fn start_and_end_for<R: RangeBounds<usize>>(&self, range: R) -> (usize, usize)

Helper method: Consumes a range and returns the corresponding start and end as a pair of usizes. Read more
Source§

fn sub<R: RangeBounds<usize>>(&self, range: R) -> BitVector<Word>

Returns a clone of the elements in the half-open range [begin, end) as a new bit-vector. Read more
Source§

fn split_at_into( &self, at: usize, left: &mut BitVector<Word>, right: &mut BitVector<Word>, )

Splits a bit-store into two parts at the given index. Read more
Source§

fn split_at(&self, at: usize) -> (BitVector<Word>, BitVector<Word>)

Splits a bit-store into two parts at the given index. The parts are returned as a pair of new bit-vectors. Read more
Source§

fn riffled_into(&self, dst: &mut BitVector<Word>)

Riffle this bit-vector into another bit-vector dst with the bits in the original vector interleaved with zeros. Read more
Source§

fn riffled(&self) -> BitVector<Word>

Returns a new bit-vector that is the result of riffling the bits in this bit-store with zeros. Read more
Source§

fn dot<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> bool

Returns the scalar dot product of this bit-store and another bit-store. Read more
Source§

fn convolved_with<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>

Returns the convolution of this bit-store and another bit-store as a new bit-vector. Read more
Source§

fn to_binary_string(&self) -> String

Returns the “binary” string representation of the bits in the bit-store. Read more
Source§

fn to_pretty_string(&self) -> String

Returns the “pretty” string representation of the bits in the bit-store. Read more
Source§

fn to_custom_binary_string( &self, separator: &str, left: &str, right: &str, ) -> String

Returns a customised “binary” string representation of the bits in the bit-store. Read more
Source§

fn to_hex_string(&self) -> String

Returns the “hex” string representation of the bits in the bit-store. Read more
Source§

fn describe(&self) -> String

Returns a multi-line string describing the bit-store in some detail. Read more
Source§

fn left_shift(&mut self, shift: usize)

Shifts all bits in the bit-store to the left by shift places. Read more
Source§

fn left_shifted(&self, shift: usize) -> BitVector<Word>

Returns a new bit-vector that is the result of left-shifting this bit-store by shift places. Read more
Source§

fn right_shift(&mut self, shift: usize)

Shifts all bits in the bit-store to the right by shift places. Read more
Source§

fn right_shifted(&self, shift: usize) -> BitVector<Word>

Returns a new bit-vector that is the result of right-shifting this bit-store by shift places. Read more
Source§

fn xor_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)

Performs an in-place bitwise XOR of this bit-store with another bit-store. Read more
Source§

fn xor<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>

Returns a new bit-vector that is the result of XOR’ing this bit-store with another. Read more
Source§

fn and_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)

Performs an in-place bitwise AND of this bit-store with another bit-store. Read more
Source§

fn and<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>

Returns a new bit-vector that is the result of AND’ing this bit-store with another. Read more
Source§

fn or_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)

Performs an in-place bitwise OR of this bit-store with another bit-store. Read more
Source§

fn or<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>

Returns a new bit-vector that is the result of OR’ing this bit-store with another. Read more
Source§

fn plus_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)

Performs an in-place addition of this bit-store with another bit-store. Read more
Source§

fn plus<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>

Returns a new bit-vector that is the result of adding this bit-store to another. Read more
Source§

fn minus_eq<Rhs: BitStore<Word>>(&mut self, rhs: &Rhs)

Performs an in-place subtraction of another bit-store from this bit-store. Read more
Source§

fn minus<Rhs: BitStore<Word>>(&self, rhs: &Rhs) -> BitVector<Word>

Returns a new bit-vector that is the result of subtracting a bit-store from this one. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>

XOR’s a BitArray reference and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>

XOR’s a BitSlice reference and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for &BitVector<Word>

XOR’s a BitVector reference and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

XOR’s a BitArray and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

XOR’s a BitSlice and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitArray<N, Word, WORDS>> for BitVector<Word>

XOR’s a BitVector and a BitArray reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>

XOR’s a BitArray reference and a BitSlice reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

XOR’s a BitArray and a BitSlice reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitVector<Word>> for &BitArray<N, Word, WORDS>

XOR’s a BitArray reference and a BitVector reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BitVector<Word>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<&BitVector<Word>> for BitArray<N, Word, WORDS>

XOR’s a BitArray and a BitVector reference, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &BitVector<Word>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>

XOR’s a BitArray reference and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>

XOR’s a BitSlice reference and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for &BitVector<Word>

XOR’s a BitVector reference and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

XOR’s a BitSlice and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitArray<N, Word, WORDS>> for BitVector<Word>

XOR’s a BitVector and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>

XOR’s a BitArray reference and a BitSlice, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

XOR’s a BitArray and a BitSlice, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitVector<Word>> for &BitArray<N, Word, WORDS>

XOR’s a BitArray reference and a BitVector, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitVector<Word>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor<BitVector<Word>> for BitArray<N, Word, WORDS>

XOR’s a BitArray and a BitVector, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitVector<Word>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXor for BitArray<N, Word, WORDS>

XOR’s a BitArray and a BitArray, returning a new bit-vector.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = BitVector<Word>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

In-place XOR’s a BitArray with a BitArray reference.

§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>)

Performs the ^= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

In-place XOR’s a BitSlice with a BitArray reference.

§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>)

Performs the ^= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>

In-place XOR’s a BitVector with a BitArray reference.

§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>)

Performs the ^= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

In-place XOR’s a BitArray with a BitSlice reference.

§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>)

Performs the ^= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>

In-place XOR’s a BitArray with a BitVector reference.

§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>)

Performs the ^= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

In-place XOR’s a BitSlice with a BitArray.

§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>)

Performs the ^= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitArray<N, Word, WORDS>> for BitVector<Word>

In-place XOR’s a BitVector with a BitArray.

§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>)

Performs the ^= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

In-place XOR’s a BitArray with a BitSlice.

§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>)

Performs the ^= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign<BitVector<Word>> for BitArray<N, Word, WORDS>

In-place XOR’s a BitArray with a BitVector.

§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>)

Performs the ^= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> BitXorAssign for BitArray<N, Word, WORDS>

In-place XOR’s a BitArray with a BitArray.

§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>)

Performs the ^= operation. Read more
Source§

impl<const N: usize, Word: Clone + Unsigned, const WORDS: usize> Clone for BitArray<N, Word, WORDS>

Source§

fn clone(&self) -> BitArray<N, Word, WORDS>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const 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§

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

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

impl<const N: usize, Word: Unsigned, const WORDS: usize> Default for BitArray<N, Word, WORDS>

Implement the Default trait for a bit-array.

Source§

fn default() -> Self

The default constructor creates a bit-array with all the bits set to 0.

§Examples
use gf2::*;
let v: BitArray<10, u8> = BitArray::default();
assert_eq!(v.len(), 10);
assert_eq!(v.words(), 2);
assert_eq!(v.to_string(), "0000000000");
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.

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 with 0b.

§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§

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

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

impl<const N: usize, Word: Hash + Unsigned, const WORDS: usize> Hash for BitArray<N, Word, WORDS>

Source§

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

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

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

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

impl<const N: usize, Word: Unsigned, const WORDS: usize> Index<usize> for BitArray<N, Word, WORDS>

std::ops::Index<usize> for a BitArray.

Returns the value of element i in the type.

§Panics

In debug mode, panics if the passed index is out of bounds.

§Examples

use gf2::*;
let mut v: gf2::BitVector = gf2::BitVector::ones(37);
assert_eq!(v[10], true);
v.set(10, false);
assert_eq!(v[10], false);
Source§

type Output = bool

The returned type after indexing.
Source§

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

Performs the indexing (container[index]) operation. Read more
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.

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.

  • 0x1 is the hex representation of the bit-vector 0001 => length 4.
  • 0x1.8 is the hex representation of the bit-vector 001 => length 3.
  • 0x1.4 is the hex representation of the bit-vector 01 => length 2.
  • 0x1.2 is the hex representation of the bit-vector 1 => 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 with 0x.

§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§

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

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

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>

The dot product a BitArray reference and a BitArray reference, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
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.

Matrix-vector multiplication returning &M * &v as a new BitVector.

§Panics

Panics if the operands have incompatible dimensions.

Source§

type Output = BitVector<Word>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>

The dot product a BitSlice reference and a BitArray reference, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for &BitVector<Word>

The dot product a BitVector reference and a BitArray reference, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

The dot product a BitArray and a BitArray reference, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
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.

Matrix-vector multiplication returning M * &v as a new BitVector.

§Panics

Panics if the operands have incompatible dimensions.

Source§

type Output = BitVector<Word>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

The dot product a BitSlice and a BitArray reference, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitArray<N, Word, WORDS>> for BitVector<Word>

The dot product a BitVector and a BitArray reference, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
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.

Vector-matrix multiplication returning &v * &M as a new BitVector.

§Panics

Panics if the operands have incompatible dimensions.

Source§

type Output = BitVector<Word>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitMatrix<Word>) -> Self::Output

Performs the * operation. Read more
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.

Vector-matrix multiplication returning v * &M as a new BitVector.

§Panics

Panics if the operands have incompatible dimensions.

Source§

type Output = BitVector<Word>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitMatrix<Word>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>

The dot product a BitArray reference and a BitSlice reference, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

The dot product a BitArray and a BitSlice reference, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitVector<Word>> for &BitArray<N, Word, WORDS>

The dot product a BitArray reference and a BitVector reference, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitVector<Word>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<&BitVector<Word>> for BitArray<N, Word, WORDS>

The dot product a BitArray and a BitVector reference, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &BitVector<Word>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitArray<N, Word, WORDS>

The dot product a BitArray reference and a BitArray, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
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.

Matrix-vector multiplication returning &M * v as a new BitVector.

§Panics

Panics if the operands have incompatible dimensions.

Source§

type Output = BitVector<Word>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitSlice<'a, Word>

The dot product a BitSlice reference and a BitArray, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for &BitVector<Word>

The dot product a BitVector reference and a BitArray, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
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.

Matrix-vector multiplication returning M * v as a new BitVector.

§Panics

Panics if the operands have incompatible dimensions.

Source§

type Output = BitVector<Word>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

The dot product a BitSlice and a BitArray, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitArray<N, Word, WORDS>> for BitVector<Word>

The dot product a BitVector and a BitArray, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
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.

Vector-matrix multiplication returning &v * M as a new BitVector.

§Panics

Panics if the operands have incompatible dimensions.

Source§

type Output = BitVector<Word>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitMatrix<Word>) -> Self::Output

Performs the * operation. Read more
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.

Vector-matrix multiplication returning &v * M as a new BitVector.

§Panics

Panics if the operands have incompatible dimensions.

Source§

type Output = BitVector<Word>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitMatrix<Word>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitSlice<'a, Word>> for &BitArray<N, Word, WORDS>

The dot product a BitArray reference and a BitSlice, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

The dot product a BitArray and a BitSlice, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitVector<Word>> for &BitArray<N, Word, WORDS>

The dot product a BitArray reference and a BitVector, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitVector<Word>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul<BitVector<Word>> for BitArray<N, Word, WORDS>

The dot product a BitArray and a BitVector, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitVector<Word>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Mul for BitArray<N, Word, WORDS>

The dot product a BitArray and a BitArray, returning a bool.

§Panics

This method panics if the lengths of the input operands do not match.

Source§

type Output = bool

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the * operation. Read more
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.

§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§

type Output = BitVector<Word>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
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.

§Examples

use gf2::*;
let u: gf2::BitVector = gf2::BitVector::ones(3);
let v = !u;
assert_eq!(v.to_binary_string(), "000");
Source§

type Output = BitVector<Word>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<const N: usize, Word: Ord + Unsigned, const WORDS: usize> Ord for BitArray<N, Word, WORDS>

Source§

fn cmp(&self, other: &BitArray<N, Word, WORDS>) -> Ordering

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

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

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

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

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

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

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

impl<const N: usize, Word: PartialEq + Unsigned, const WORDS: usize> PartialEq for BitArray<N, Word, WORDS>

Source§

fn eq(&self, other: &BitArray<N, Word, WORDS>) -> bool

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

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

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

impl<const N: usize, Word: PartialOrd + Unsigned, const WORDS: usize> PartialOrd for BitArray<N, Word, WORDS>

Source§

fn partial_cmp(&self, other: &BitArray<N, Word, WORDS>) -> Option<Ordering>

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

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

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

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

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

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

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

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

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

impl<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§

type Output = BitVector<Word>

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

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

Performs the << operation. Read more
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.

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§

type Output = BitVector<Word>

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

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

Performs the << operation. Read more
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.

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)

Performs the <<= operation. Read more
Source§

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§

type Output = BitVector<Word>

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

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

Performs the >> operation. Read more
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.

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§

type Output = BitVector<Word>

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

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

Performs the >> operation. Read more
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.

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)

Performs the >>= operation. Read more
Source§

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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
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.

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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
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.

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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

Subtracts a BitArray 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

Subtracts a BitSlice 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitArray<N, Word, WORDS>> for BitVector<Word>

Subtracts a BitVector 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
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.

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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

Subtracts a BitArray 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &BitSlice<'a, Word>) -> Self::Output

Performs the - operation. Read more
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.

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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &BitVector<Word>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<&BitVector<Word>> for BitArray<N, Word, WORDS>

Subtracts a BitArray 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &BitVector<Word>) -> Self::Output

Performs the - operation. Read more
Source§

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, 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
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, 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
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, 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

Subtracts a BitSlice and a BitArray, 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitArray<N, Word, WORDS>> for BitVector<Word>

Subtracts a BitVector and a BitArray, 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
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, 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

Subtracts a BitArray and a BitSlice, 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitSlice<'a, Word>) -> Self::Output

Performs the - operation. Read more
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, 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitVector<Word>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub<BitVector<Word>> for BitArray<N, Word, WORDS>

Subtracts a BitArray and a BitVector, 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitVector<Word>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> Sub for BitArray<N, Word, WORDS>

Subtracts a BitArray and a BitArray, 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§

type Output = BitVector<Word>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitArray<N, Word, WORDS>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitArray<N, Word, WORDS>> for BitArray<N, Word, WORDS>

In-place subtraction of a BitArray with a BitArray reference.

§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>)

Performs the -= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

In-place subtraction of a BitSlice with a BitArray reference.

§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>)

Performs the -= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitArray<N, Word, WORDS>> for BitVector<Word>

In-place subtraction of a BitVector with a BitArray reference.

§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>)

Performs the -= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

In-place subtraction of a BitArray with a BitSlice reference.

§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>)

Performs the -= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<&BitVector<Word>> for BitArray<N, Word, WORDS>

In-place subtraction of a BitArray with a BitVector reference.

§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>)

Performs the -= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitArray<N, Word, WORDS>> for BitSlice<'a, Word>

In-place subtraction of a BitSlice with a BitArray.

§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>)

Performs the -= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitArray<N, Word, WORDS>> for BitVector<Word>

In-place subtraction of a BitVector with a BitArray.

§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>)

Performs the -= operation. Read more
Source§

impl<'a, const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitSlice<'a, Word>> for BitArray<N, Word, WORDS>

In-place subtraction of a BitArray with a BitSlice.

§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>)

Performs the -= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign<BitVector<Word>> for BitArray<N, Word, WORDS>

In-place subtraction of a BitArray with a BitVector.

§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>)

Performs the -= operation. Read more
Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> SubAssign for BitArray<N, Word, WORDS>

In-place subtraction of a BitArray with a BitArray.

§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>)

Performs the -= operation. Read more
Source§

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.

  • 0X1 is the hex representation of the bit-vector 0001 => length 4.
  • 0X1.8 is the hex representation of the bit-vector 001 => length 3.
  • 0X1.4 is the hex representation of the bit-vector 01 => length 2.
  • 0X1.2 is the hex representation of the bit-vector 1 => 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 with 0X.

§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§

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

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

impl<const N: usize, Word: Eq + Unsigned, const WORDS: usize> Eq for BitArray<N, Word, WORDS>

Source§

impl<const N: usize, Word: Unsigned, const WORDS: usize> StructuralPartialEq for BitArray<N, Word, WORDS>

Auto Trait Implementations§

§

impl<const N: usize, Word, const WORDS: usize> Freeze for BitArray<N, Word, WORDS>
where Word: Freeze,

§

impl<const N: usize, Word, const WORDS: usize> RefUnwindSafe for BitArray<N, Word, WORDS>
where Word: RefUnwindSafe,

§

impl<const N: usize, Word, const WORDS: usize> Send for BitArray<N, Word, WORDS>

§

impl<const N: usize, Word, const WORDS: usize> Sync for BitArray<N, Word, WORDS>

§

impl<const N: usize, Word, const WORDS: usize> Unpin for BitArray<N, Word, WORDS>

§

impl<const N: usize, Word, const WORDS: usize> UnwindSafe for BitArray<N, Word, WORDS>
where Word: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.