#memoization #upsert #memo

memo-map

A crate implementing a synchronized map for memoization

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

#255 in Concurrency

Download history 55102/week @ 2025-10-11 61437/week @ 2025-10-18 65064/week @ 2025-10-25 66913/week @ 2025-11-01 62766/week @ 2025-11-08 80804/week @ 2025-11-15 59254/week @ 2025-11-22 70665/week @ 2025-11-29 93148/week @ 2025-12-06 91430/week @ 2025-12-13 52479/week @ 2025-12-20 42640/week @ 2025-12-27 86434/week @ 2026-01-03 97670/week @ 2026-01-10 114346/week @ 2026-01-17 153399/week @ 2026-01-24

459,208 downloads per month
Used in 214 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