diff --git a/CHANGELOG.md b/CHANGELOG.md index 90e7cd2b..cdfcd481 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [v0.7.9] - 2021-12-16 + +### Fixed + +- Fix `IndexMap` and `IndexSet` bounds +- Make `IndexSet::new()` a `const fn` + ## [v0.7.8] - 2021-11-11 ### Added @@ -423,8 +430,9 @@ architecture. - Initial release -[Unreleased]: https://github.com/japaric/heapless/compare/v0.7.8...HEAD -[v0.7.9]: https://github.com/japaric/heapless/compare/v0.7.7...v0.7.8 +[Unreleased]: https://github.com/japaric/heapless/compare/v0.7.9...HEAD +[v0.7.9]: https://github.com/japaric/heapless/compare/v0.7.8...v0.7.9 +[v0.7.8]: https://github.com/japaric/heapless/compare/v0.7.7...v0.7.8 [v0.7.7]: https://github.com/japaric/heapless/compare/v0.7.6...v0.7.7 [v0.7.6]: https://github.com/japaric/heapless/compare/v0.7.5...v0.7.6 [v0.7.5]: https://github.com/japaric/heapless/compare/v0.7.4...v0.7.5 diff --git a/Cargo.toml b/Cargo.toml index 5a448031..bfedb936 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["static", "no-heap"] license = "MIT OR Apache-2.0" name = "heapless" repository = "https://github.com/japaric/heapless" -version = "0.7.8" +version = "0.7.9" [features] default = ["cas"] diff --git a/src/indexmap.rs b/src/indexmap.rs index 100d7009..beedcb10 100644 --- a/src/indexmap.rs +++ b/src/indexmap.rs @@ -368,6 +368,10 @@ pub struct IndexMap { impl IndexMap, N> { /// Creates an empty `IndexMap`. pub const fn new() -> Self { + // Const assert + crate::sealed::greater_than_1::(); + crate::sealed::power_of_two::(); + IndexMap { build_hasher: BuildHasherDefault::new(), core: CoreMap::new(), diff --git a/src/indexset.rs b/src/indexset.rs index 23256471..fbf33360 100644 --- a/src/indexset.rs +++ b/src/indexset.rs @@ -1,6 +1,6 @@ use crate::indexmap::{self, IndexMap}; use core::{borrow::Borrow, fmt, iter::FromIterator}; -use hash32::{BuildHasher, BuildHasherDefault, FnvHasher, Hash, Hasher}; +use hash32::{BuildHasher, BuildHasherDefault, FnvHasher, Hash}; /// A [`heapless::IndexSet`](./struct.IndexSet.html) using the /// default FNV hasher. @@ -74,22 +74,13 @@ pub type FnvIndexSet = IndexSet -where - T: Eq + Hash, -{ +pub struct IndexSet { map: IndexMap, } -impl IndexSet, N> -where - T: Eq + Hash, - S: Default + Hasher, -{ +impl IndexSet, N> { /// Creates an empty `IndexSet` - pub fn new() -> Self { - assert!(N.is_power_of_two()); - + pub const fn new() -> Self { IndexSet { map: IndexMap::new(), }