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 4090/week @ 2023-12-11 3965/week @ 2023-12-18 1934/week @ 2023-12-25 3177/week @ 2024-01-01 4427/week @ 2024-01-08 4035/week @ 2024-01-15 4828/week @ 2024-01-22 4539/week @ 2024-01-29 5307/week @ 2024-02-05 4926/week @ 2024-02-12 4590/week @ 2024-02-19 5340/week @ 2024-02-26 5186/week @ 2024-03-04 5855/week @ 2024-03-11 6893/week @ 2024-03-18 5071/week @ 2024-03-25

23,283 downloads per month
Used in 41 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