Skip to content

Commit 1379a98

Browse files
committed
compile-time check power of two invariant in Index{Set,Map}'s default method
closes #295
1 parent 3927389 commit 1379a98

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/indexmap.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,10 @@ where
952952
S: BuildHasher + Default,
953953
{
954954
fn default() -> Self {
955+
// Const assert
956+
crate::sealed::greater_than_1::<N>();
957+
crate::sealed::power_of_two::<N>();
958+
955959
IndexMap {
956960
build_hasher: <_>::default(),
957961
core: CoreMap::new(),

0 commit comments

Comments
 (0)