Mercurial > lbo > hg > memoize
view examples/fxhash.rs @ 96:528ce50ec228
Applied comments by @dermesser
author | blyxyas <blyxyas@gmail.com> |
---|---|
date | Sun, 15 Jan 2023 13:15:04 +0100 |
parents | 7d8d8525f957 |
children |
line wrap: on
line source
use memoize::memoize; use rustc_hash::FxHashMap; #[cfg(feature = "full")] #[memoize(CustomHasher: FxHashMap, HasherInit: FxHashMap::default())] fn hello() -> bool { println!("hello!"); true } #[cfg(feature = "full")] fn main() { // `hello` is only called once here. assert!(hello()); assert!(hello()); memoized_flush_hello(); // and again here. assert!(hello()); } #[cfg(not(feature = "full"))] fn main() { println!("Use the \"full\" feature to execute this example"); }