Expand description
A two-layered map structure where the foreground is mutable and the background is preserved.
OverlayMap lets you insert values without cloning, while keeping a single layer of historical context. Each key has a current value (foreground) and may have a previous value (background), which is automatically managed during updates.
use overlay_map::Overlay;
let mut door = Overlay::new_fg("Alice");
println!("Present: {:?}, {:?}", door.fg(), door.bg());
for name in ["Bob", "Carol", "Dave", "Eve"] {
if let Some(evicted) = door.swap(name) {
println!("{evicted} left");
}
println!("Present: {:?}, {:?}", door.bg(), door.fg());
}
while let Some(pulled) = door.pull() {
println!("{pulled} left");
}
println!("Present: {:?}, {:?}", door.bg(), door.fg());
Structs§
- Overlay
- A two-layer value container used by
OverlayMap
to manage current and historical values. - Overlay
Into Iter - Overlay
Map - A two-layered map where each key holds a current (foreground) and optional historical (background) value.