1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! A configurable generational map.
//! # Examples
//!
//! ```
//! use gen_map::GenMap;
//!
//! let mut map = GenMap::new();
//! let a = map.insert("a");
//! let b = map.insert("b");
//!
//! assert_eq!(map[a], "a");
//! assert_eq!(map.remove(a), Some("a"));
//! assert!(map.get(a).is_none());
//! assert_eq!(map.len(), 1);
//!
//! for (key, value) in &map {
//! assert_eq!(key, b);
//! assert_eq!(*value, "b");
//! }
//! ```
//!
//! With a custom config:
//!
//! ```
//! use gen_map::{Config, GenMap, Key};
//!
//! struct Tiny;
//!
//! impl Config for Tiny {
//! type Idx = u8;
//! type Gen = u8;
//! }
//!
//! let mut map = GenMap::<u64, Tiny>::new_with_config();
//! let key: Key<Tiny> = map.insert(7);
//! assert_eq!(core::mem::size_of_val(&key), 2);
//! assert_eq!(map[key], 7);
//! ```
extern crate alloc;
extern crate std;
pub use ;
pub use Key;
pub use KeyPiece;
pub use ;