view examples/test1.rs @ 24:45b59350976f v0.1.4

Version: v0.1.4
author Lewin Bormann <lbo@spheniscida.de>
date Fri, 16 Oct 2020 10:30:59 +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()));
}