@@ -369,9 +369,11 @@ pub struct ChunkedBitSet<T> {
369
369
#[ derive( Clone , Debug , PartialEq , Eq ) ]
370
370
enum Chunk {
371
371
/// A chunk that is all zeros; we don't represent the zeros explicitly.
372
+ /// The `ChunkSize` is always non-zero.
372
373
Zeros ( ChunkSize ) ,
373
374
374
375
/// A chunk that is all ones; we don't represent the ones explicitly.
376
+ /// `ChunkSize` is always non-zero.
375
377
Ones ( ChunkSize ) ,
376
378
377
379
/// A chunk that has a mix of zeros and ones, which are represented
@@ -384,8 +386,10 @@ enum Chunk {
384
386
/// words are always be zero, as are any excess bits in the final in-use
385
387
/// word.
386
388
///
387
- /// The second field is the count of 1s set in the chunk, and must satisfy
388
- /// `0 < count < chunk_domain_size`.
389
+ /// The first `ChunkSize` field is always non-zero.
390
+ ///
391
+ /// The second `ChunkSize` field is the count of 1s set in the chunk, and
392
+ /// must satisfy `0 < count < chunk_domain_size`.
389
393
///
390
394
/// The words are within an `Rc` because it's surprisingly common to
391
395
/// duplicate an entire chunk, e.g. in `ChunkedBitSet::clone_from()`, or
@@ -461,7 +465,7 @@ impl<T: Idx> ChunkedBitSet<T> {
461
465
}
462
466
463
467
pub fn is_empty ( & self ) -> bool {
464
- self . chunks . iter ( ) . all ( |chunk| matches ! ( chunk, Chunk :: Zeros ( ..) | Chunk :: Ones ( 0 ) ) )
468
+ self . chunks . iter ( ) . all ( |chunk| matches ! ( chunk, Chunk :: Zeros ( ..) ) )
465
469
}
466
470
467
471
/// Returns `true` if `self` contains `elem`.
@@ -1005,7 +1009,7 @@ impl Chunk {
1005
1009
}
1006
1010
1007
1011
fn new ( chunk_domain_size : usize , is_empty : bool ) -> Self {
1008
- debug_assert ! ( chunk_domain_size <= CHUNK_BITS ) ;
1012
+ debug_assert ! ( 0 < chunk_domain_size && chunk_domain_size <= CHUNK_BITS ) ;
1009
1013
let chunk_domain_size = chunk_domain_size as ChunkSize ;
1010
1014
if is_empty { Zeros ( chunk_domain_size) } else { Ones ( chunk_domain_size) }
1011
1015
}
0 commit comments