Mercurial > lbo > hg > memoize
view examples/test1.rs @ 4:702afb217145
Set license in Cargo.toml
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Thu, 15 Oct 2020 13:28:47 +0200 |
parents | 0bc33bd08f39 |
children | 69a47879ec78 |
line wrap: on
line source
use memoize::memoize; #[derive(Debug, Clone)] struct ComplexStruct { s: String, b: bool, i: i32, } #[memoize] 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())); }