3 releases

0.3.2 Aug 27, 2023
0.3.1 Mar 20, 2022
0.2.1 Mar 20, 2022
0.1.0 Mar 20, 2022

#81 in Concurrency

Download history 5093/week @ 2024-01-31 5051/week @ 2024-02-07 4812/week @ 2024-02-14 5059/week @ 2024-02-21 4916/week @ 2024-02-28 5717/week @ 2024-03-06 6518/week @ 2024-03-13 5957/week @ 2024-03-20 5752/week @ 2024-03-27 6629/week @ 2024-04-03 7021/week @ 2024-04-10 7077/week @ 2024-04-17 6642/week @ 2024-04-24 7029/week @ 2024-05-01 6564/week @ 2024-05-08 6519/week @ 2024-05-15

28,016 downloads per month
Used in 42 crates (2 directly)

Apache-2.0

19KB
311 lines

memo-map

Build Status Crates.io License rustc 1.41.0 Documentation

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.
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");

No runtime deps