fn_once

This library provides a convenient derive macro for a once function.

CI Crates.io Licensed Twitter

toml fn_once = "0.2.0"

How to use,

```rust use fn_once::once;

[once]

fn print_once(name: &str) { println!("Hello! {}!", name); }

[once(or = { number })] // or = { ... }

fn addoneonce(number: u32) -> u32 { count + 1 }

[once(panic)]

fn panicwhentwice() { }

fn main() { printonce("World"); // print "Hello! World!" printonce("foo"); // no effect

let mut number = 0;
number = add_one_once(number); // 0 + 1 -> 1
number = add_one_once(number); // no effect -> 1
number = add_one_once(number); // no effect -> 1
assert_eq!(number, 1);

panic_when_twice();
panic_when_twice(); // panic!

} ```