once_map-0.4.3 has been yanked.
once_map
This crate provides OnceMap, a type of HashMap where entries can be written with a shared reference,
but can be written ony once. This is similar to once_cell, but with a map.
This enables to reference values inside the map for the lifetime of the map, without the need
of further locks.
This makes this type perfect for implementation of caches. A type LazyMap is provided for such cases.
This crate provides such a map heavily optimized for concurrent use, but also a single-threaded version.
Example
let map = new;
// All these are `&str` pointing directly in the map.
// Note that we don't need a mutable reference, so we can have several of
// them at the same time.
let roses = map.insert;
let violets = map.insert;
let sugar = map.insert;
assert_eq!;
assert_eq!;
assert_eq!;
// The closure is never run here, because we already have a value for "rose"
let roses = map.insert;
// The old value did not change
assert_eq!;