view examples/test2.rs @ 43:a9b3e08f1ae5

Remove unused_import warning and run rustfmt
author Lewin Bormann <lbo@spheniscida.de>
date Thu, 10 Dec 2020 20:22:32 +0100
parents 69a47879ec78
children
line wrap: on
line source

use memoize::memoize;

#[memoize]
fn hello(arg: String, arg2: usize) -> bool {
    println!("{} => {}", arg, arg2);
    arg.len() % 2 == arg2
}

fn main() {
    // `hello` is only called once here.
    assert!(!hello("World".to_string(), 0));
    assert!(!hello("World".to_string(), 0));
    // Sometimes one might need the original function.
    assert!(!memoized_original_hello("World".to_string(), 0));
}