mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-09-28 04:50:34 +00:00
Cleanup
This commit is contained in:
parent
305de719f6
commit
3de878b09e
@ -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>
|
||||
{
|
||||
const fn new() -> Self {
|
||||
const INIT: Option<Pos> = None;
|
||||
|
||||
CoreMap {
|
||||
entries: Vec::new(),
|
||||
indices: [INIT; 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 {
|
||||
CoreMap {
|
||||
entries: Vec::new(),
|
||||
indices: unsafe { MaybeUninit::zeroed().assume_init() },
|
||||
}
|
||||
}
|
||||
|
||||
fn capacity() -> usize {
|
||||
N
|
||||
}
|
||||
|
@ -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
|
||||
@ -89,6 +88,8 @@ where
|
||||
{
|
||||
/// Creates an empty `IndexSet`
|
||||
pub fn new() -> Self {
|
||||
assert!(N.is_power_of_two());
|
||||
|
||||
IndexSet {
|
||||
map: IndexMap::new(),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user