fn_once
This library provides a convenient derive macro for a once function.
toml
fn_once = "0.3.0"
How to use,
```rust use fn_once::once;
fn print_once(name: &str) { println!("Hello! {}!", name); }
fn addoneonce(number: u32) -> u32 { count + 1 }
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!
} ```
When you want to disable it,
```toml [features] default = ["onceoff"] onceoff = []
once_off
feature is turned on.```