Skip to content

Commit

Permalink
Add an example that uses SharedCache
Browse files Browse the repository at this point in the history
This will catch the compile error on `cargo test`.
  • Loading branch information
rsaarelm committed Aug 4, 2023
1 parent abd3d17 commit 2d43d48
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/shared.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use memoize::memoize;

#[memoize(SharedCache)]
fn hello(arg: String, arg2: usize) -> bool {
println!("{} => {}", arg, arg2);
arg.len() % 2 == arg2
}

fn main() {
// `hello` is only called once here.
assert!(!hello("World".to_string(), 0));
assert!(!hello("World".to_string(), 0));
// Sometimes one might need the original function.
assert!(!memoized_original_hello("World".to_string(), 0));
memoized_flush_hello();
}

0 comments on commit 2d43d48

Please sign in to comment.