view examples/empty.rs @ 85:fbf408e00f17

Fix #17: Allow memoizing functions with no arguments
author Lewin Bormann <lbo@spheniscida.de>
date Fri, 02 Dec 2022 21:03:43 +0100
parents
children
line wrap: on
line source

//! Reproduces (verifies) issue #17: Panics when used on fn without args.

use memoize::memoize;

#[memoize]
fn hello() -> bool {
    println!("hello!");
    true
}

fn main() {
    // `hello` is only called once here.
    assert!(hello());
    assert!(hello());
    memoized_flush_hello();
    // and again here.
    assert!(hello());
}