Mercurial > lbo > hg > memoize
view examples/test1.rs @ 22:c15379dd7de7
Improve README explanations.
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Fri, 16 Oct 2020 10:12:43 +0200 |
parents | 2c254214df2e |
children | 36657c45bae5 |
line wrap: on
line source
use memoize::memoize; #[derive(Debug, Clone)] struct ComplexStruct { s: String, b: bool, i: i32, } #[memoize(Capacity: 123)] fn hello(key: String) -> ComplexStruct { println!("hello: {}", key); ComplexStruct { s: key, b: false, i: 332, } } fn main() { println!("result: {:?}", hello("ABC".to_string())); println!("result: {:?}", hello("DEF".to_string())); println!("result: {:?}", hello("ABC".to_string())); println!("result: {:?}", memoized_original_hello("ABC".to_string())); }