#memo #upsert

memo-map

A crate implementing a synchronized map for memoization

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

#230 in Concurrency

Download history 2264/week @ 2023-06-08 1650/week @ 2023-06-15 1231/week @ 2023-06-22 1315/week @ 2023-06-29 1816/week @ 2023-07-06 2350/week @ 2023-07-13 2375/week @ 2023-07-20 2340/week @ 2023-07-27 2881/week @ 2023-08-03 2977/week @ 2023-08-10 2886/week @ 2023-08-17 2815/week @ 2023-08-24 1940/week @ 2023-08-31 3036/week @ 2023-09-07 2620/week @ 2023-09-14 2167/week @ 2023-09-21

10,288 downloads per month
Used in 16 crates (via minijinja)

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