cache-macro 0.4.1

A procedural macro for automatically caching the output of functions.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use cache_macro::cache;
use lru_cache::LruCache;

#[test]
fn args_as_ref() {
    #[cache(LruCache : LruCache::new(20))]
    fn fib(x: &u32) -> u64 {
        println!("{:?}", x);
        if *x <= 1 {
            1
        } else {
            fib(&(x - 1)) + fib(&(x - 2))
        }
    }

    assert_eq!(fib(&19), 6765);
}