4 releases

0.3.3 Jul 28, 2024
0.3.2 Aug 27, 2023
0.3.1 Mar 20, 2022
0.2.1 Mar 20, 2022
0.1.0 Mar 20, 2022

#77 in Concurrency

Download history 40523/week @ 2025-03-09 42400/week @ 2025-03-16 33396/week @ 2025-03-23 29889/week @ 2025-03-30 32975/week @ 2025-04-06 25321/week @ 2025-04-13 31103/week @ 2025-04-20 35447/week @ 2025-04-27 34676/week @ 2025-05-04 36408/week @ 2025-05-11 41865/week @ 2025-05-18 36614/week @ 2025-05-25 32535/week @ 2025-06-01 37685/week @ 2025-06-08 37427/week @ 2025-06-15 37371/week @ 2025-06-22

147,175 downloads per month
Used in 112 crates (5 directly)

Apache-2.0

21KB
356 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