| 1 | # memo-map |
| 2 | |
| 3 | [](https://github.com/mitsuhiko/memo-map/actions?query=workflow%3ATests) |
| 4 | [](https://crates.io/crates/memo-map) |
| 5 | [](https://github.com/mitsuhiko/memo-map/blob/main/LICENSE) |
| 6 | [](https://img.shields.io/badge/rust-1.43%2B-orange.svg) |
| 7 | [](https://docs.rs/memo-map) |
| 8 | |
| 9 | A concurrent insert only hash map. |
| 10 | |
| 11 | This crate implements a “memo map” which is in many ways similar to a HashMap with some crucial differences: |
| 12 | |
| 13 | * Unlike a regular hash map, a memo map is thread safe and synchronized. |
| 14 | * Adding or retrieving keys works through a shared reference, removing only |
| 15 | through a mutable reference. |
| 16 | * Retrieving a value from a memo map returns a plain old reference. |
| 17 | |
| 18 | ```rust |
| 19 | use memo_map::MemoMap; |
| 20 | |
| 21 | let memo = MemoMap::new(); |
| 22 | let one = memo.get_or_insert(&1, || "one".to_string()); |
| 23 | let one2 = memo.get_or_insert(&1, || "not one".to_string()); |
| 24 | assert_eq!(one, "one"); |
| 25 | assert_eq!(one2, "one"); |
| 26 | ``` |
| 27 | |
| 28 | ## License and Links |
| 29 | |
| 30 | - [Documentation](https://docs.rs/memo-map/) |
| 31 | - [Issue Tracker](https://github.com/mitsuhiko/memo-map/issues) |
| 32 | - License: [Apache-2.0](https://github.com/mitsuhiko/memo-map/blob/main/LICENSE) |
| 33 |