view examples/test1.rs @ 5:5b4d00ea008d

Extend README.
author Lewin Bormann <lbo@spheniscida.de>
date Thu, 15 Oct 2020 13:29:59 +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()));
}