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
|
# memo-map
[](https://github.com/mitsuhiko/memo-map/actions?query=workflow%3ATests)
[](https://crates.io/crates/memo-map)
[](https://github.com/mitsuhiko/memo-map/blob/main/LICENSE)
[](https://img.shields.io/badge/rust-1.43%2B-orange.svg)
[](https://docs.rs/memo-map)
A concurrent insert only hash map.
This crate implements a “memo map” which is in many ways similar to a HashMap with some crucial differences:
* Unlike a regular hash map, a memo map is thread safe and synchronized.
* Adding or retrieving keys works through a shared reference, removing only
through a mutable reference.
* Retrieving a value from a memo map returns a plain old reference.
```rust
use memo_map::MemoMap;
let memo = MemoMap::new();
let one = memo.get_or_insert(&1, || "one".to_string());
let one2 = memo.get_or_insert(&1, || "not one".to_string());
assert_eq!(one, "one");
assert_eq!(one2, "one");
```
## License and Links
- [Documentation](https://docs.rs/memo-map/)
- [Issue Tracker](https://github.com/mitsuhiko/memo-map/issues)
- License: [Apache-2.0](https://github.com/mitsuhiko/memo-map/blob/main/LICENSE)
|