Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
korken89 committed Mar 25, 2021
1 parent 305de71 commit 3de878b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/indexmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,27 @@ macro_rules! probe_loop {
}

struct CoreMap<K, V, const N: usize>
where
K: Eq + Hash,
{
entries: Vec<Bucket<K, V>, N>,
indices: [Option<Pos>; N],
}

impl<K, V, const N: usize> CoreMap<K, V, N>
where
K: Eq + Hash,
{
// TODO turn into a `const fn`; needs `mem::zeroed` to be a `const fn`
fn new() -> Self {
const fn new() -> Self {
const INIT: Option<Pos> = None;

CoreMap {
entries: Vec::new(),
indices: unsafe { MaybeUninit::zeroed().assume_init() },
indices: [INIT; N],
}
}
}

impl<K, V, const N: usize> CoreMap<K, V, N>
where
K: Eq + Hash,
{
fn capacity() -> usize {
N
}
Expand Down
3 changes: 2 additions & 1 deletion src/indexset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::indexmap::{self, IndexMap};
use core::{borrow::Borrow, fmt, iter::FromIterator};
use hash32::{BuildHasher, BuildHasherDefault, FnvHasher, Hash, Hasher};

// TODO: We don't enforce the power of 2 currently (part of generic array bounds)
/// A [`heapless::IndexSet`](./struct.IndexSet.html) using the
/// default FNV hasher.
/// A list of all Methods and Traits available for `FnvIndexSet` can be found in
Expand Down Expand Up @@ -89,6 +88,8 @@ where
{
/// Creates an empty `IndexSet`
pub fn new() -> Self {
assert!(N.is_power_of_two());

IndexSet {
map: IndexMap::new(),
}
Expand Down

0 comments on commit 3de878b

Please sign in to comment.