#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

#300 in Concurrency

Download history 78738/week @ 2025-12-18 40889/week @ 2025-12-25 61219/week @ 2026-01-01 96619/week @ 2026-01-08 100621/week @ 2026-01-15 148214/week @ 2026-01-22 154853/week @ 2026-01-29 165054/week @ 2026-02-05 155123/week @ 2026-02-12 163088/week @ 2026-02-19 192301/week @ 2026-02-26 222608/week @ 2026-03-05 254045/week @ 2026-03-12 311698/week @ 2026-03-19 288281/week @ 2026-03-26 290256/week @ 2026-04-02

1,184,578 downloads per month
Used in 626 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