enum Chunk {
    Zeros(u16),
    Ones(u16),
    Mixed(u16u16Rc<[u64; 32]>),
}

Variants

Zeros(u16)

A chunk that is all zeros; we don’t represent the zeros explicitly.

Ones(u16)

A chunk that is all ones; we don’t represent the ones explicitly.

Mixed(u16u16Rc<[u64; 32]>)

A chunk that has a mix of zeros and ones, which are represented explicitly and densely. It never has all zeros or all ones.

If this is the final chunk there may be excess, unused words. This turns out to be both simpler and have better performance than allocating the minimum number of words, largely because we avoid having to store the length, which would make this type larger. These excess words are always be zero, as are any excess bits in the final in-use word.

The second field is the count of 1s set in the chunk, and must satisfy 0 < count < chunk_domain_size.

The words are within an Rc because it’s surprisingly common to duplicate an entire chunk, e.g. in ChunkedBitSet::clone_from(), or when a Mixed chunk is union’d into a Zeros chunk. When we do need to modify a chunk we use Rc::make_mut.

Implementations

Count the number of 1s in the chunk.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.

Layout

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 16 bytes

Size for each variant:

  • Zeros: 2 bytes
  • Ones: 2 bytes
  • Mixed: 14 bytes