pub struct BitField { /* private fields */ }
Expand description

A bit field with buffered insertion/removal that serializes to/from RLE+. Similar to HashSet<usize>, but more memory-efficient when long runs of 1s and 0s are present.

Implementations

Decodes RLE+ encoded bytes into a bit field.

Turns a bit field into its RLE+ encoded form.

Creates an empty bit field.

Creates a new bit field from a RangeIterator.

Adds the bit at a given index to the bit field.

Removes the bit at a given index from the bit field.

Returns true if the bit field contains the bit at a given index.

Returns the index of the lowest bit present in the bit field.

Returns the index of the highest bit present in the bit field. Errors if no bits are set. Merges set/unset into ranges, so be cautious with use if set is pretty populated

Returns an iterator over the indices of the bit field’s set bits.

Returns an iterator over the indices of the bit field’s set bits if the number of set bits in the bit field does not exceed max. Returns an error otherwise.

Returns an iterator over the ranges of set bits that make up the bit field. The ranges are in ascending order, are non-empty, and don’t overlap.

Returns true if the bit field is empty.

Returns a slice of the bit field with the start index of set bits and number of bits to include in the slice. Returns an error if the bit field contains fewer than start + len set bits.

Returns the number of set bits in the bit field.

Returns a new bit field containing the bits in self that remain after “cutting” out the bits in other, and shifting remaining bits to the left if necessary. For example:

lhs:     xx-xxx--x
rhs:     -xx-x----

cut:     x  x x--x
output:  xxx--x

Returns the union of the given bit fields as a new bit field.

Returns true if self overlaps with other.

Returns true if the self is a superset of other.

Trait Implementations

The resulting type after applying the & operator.

Performs the & operation. Read more

Performs the &= operation. Read more

The resulting type after applying the | operator.

Performs the | operation. Read more

Performs the |= operation. Read more

The resulting type after applying the ^ operator.

Performs the ^ operation. Read more

Performs the ^= operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

Creates a value from an iterator. Read more

Creates a value from an iterator. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.