memorize 2.0.0

Versatile and fast closure cacher with support for recursive algorithms
Documentation
  • Coverage
  • 83.33%
    5 out of 6 items documented1 out of 6 items with examples
  • Size
  • Source code size: 10.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.55 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • lbfalvy/memorize
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lbfalvy

Cache the return values of an effectless closure in a hashmap. Inspired by the closure_cacher crate, but attempts to provide a more versatile implementation.

use memorize::{cached, Cache};

let demo = cached(|arg, _| arg * 2);
assert_eq!(demo.find(&7), 14);

The second argument is a callback, it can be used for recursion.

use memorize::{cached, Cache};

let demo = cached(|arg, r| match arg {
  1 | 2 => 1,
  n => r(&(n - 1)) + r(&(n - 2)),
});
assert_eq!(demo.find(&15), 610)