mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-09-27 12:30:35 +00:00
Merge #298
298: compile-time check power of two invariant in Index{Set,Map}'s default method r=korken89 a=japaric closes #295 I tested this manually with both `FnvIndexSet` and `FnvIndexMap`. I tried to add a compile fail test but discovered (the hard way) that all the const assert trickery in `sealed` is checked when the code is built with `cargo build` but *not* when the code is built with `cargo check`. As `trybuild` uses `cargo check` under the hood it's not possible to compile fail test any of those const asserts. r? `@korken89` Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
This commit is contained in:
commit
0a844a0204
@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
### Fixed
|
||||
|
||||
- `IndexSet` and `IndexMap`'s `default` method now compile time checks that their capacity is a power of two.
|
||||
|
||||
## [v0.7.13] - 2022-05-16
|
||||
|
||||
### Added
|
||||
|
@ -952,6 +952,10 @@ where
|
||||
S: BuildHasher + Default,
|
||||
{
|
||||
fn default() -> Self {
|
||||
// Const assert
|
||||
crate::sealed::greater_than_1::<N>();
|
||||
crate::sealed::power_of_two::<N>();
|
||||
|
||||
IndexMap {
|
||||
build_hasher: <_>::default(),
|
||||
core: CoreMap::new(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user