The old logic would be ok with *either* 0 or all 1s in the last word,
because it didn't compute a proper mask for the case where nbits is an
exact multiple of u32::BITS.
Add mask_for_bits() to compute this properly, and use it in all(). Add
all/none assertions to most of the tests. Note in particular, the all-zero
bitv in test_32_elements() was incorrectly all()==true before this patch.
- Fix typos on Blocks and MutBlocks.
- Use slice_to_mut() for creating blocks_mut().
- Deref the block parameter in get().
- Access nbits separately from mutating set in pop().
Part of #18424
This commit changes the semantics of `reserve` and `capacity` for Bitv and BitvSet to match conventions. It also introduces the notion of `reserve_index` and `reserve_index_exact` for collections with maximum-index-based capacity semantics.
Deprecates free function constructors in favour of functions on Bitv itself.
Changes `Bitv::pop` to return an Option rather than panicking.
Deprecates and renames several methods in favour of conventions.
Marks several blessed methods as unstable.
This commit also substantially refactors Bitv and BitvSet's implementations. The new implementation is simpler, cleaner, better documented, and more robust against overflows. It also reduces coupling between Bitv and BitvSet. Tests have been seperated into seperate submodules.
Fixes#16958
[breaking-change]
The `is_power_of_two()` method of the `UnsignedInt` trait currently returns `true` for `self == 0`. Zero is not a power of two, assuming an integral exponent `k >= 0`. I've therefore moved this functionality to the new method `is_power_of_two_or_zero()` and reformed `is_power_of_two()` to return false for `self == 0`.
To illustrate the usefulness of the existence of both functions, consider `HashMap`. Its capacity must be zero or a power of two; conversely, it also requires a (non-zero) power of two for key and val alignment.
Also, added a small amount of documentation regarding #18604.
parse_ty() no longer takes a boolean parameter. quote_ty! implementation has not yet been modified accordingly.
As a matter of fact, quote_ty! was not covered by tests. One test (called qquotes) references it, but it has been ignored for nearly one year and now need heavy refactoring.
quote_token.rs seemed like a good place to test quote_ty!, many other quote_*! macros were asserted there.