3 stable releases
1.0.2 | Aug 2, 2020 |
---|---|
1.0.0 | Aug 1, 2020 |
#2031 in Algorithms
7KB
117 lines
lazy_futuristic
Initialize variables lazily, futuristically.
Usage
See the documentation.
Hacking
This repository uses semantic-release for automated release and crate publishing. Please look at Angular commit convention.
To test this crate:
cargo test
License
MIT.
lib.rs
:
Initialize variables lazily.
Instead of requiring a closure to initialize the value, caller can acts based on returned ValueOrSetter
.
Example
use lazy_futuristic::Lazy;
use lazy_futuristic::ValueOrSetter::*;
let lazy_number: Lazy<i32> = Lazy::new();
let number = match lazy_number.get_or_set().await {
Value(value) => value,
Setter(setter) => setter.set(10),
};
assert_eq!(*number, 10);
Dependencies
~1MB
~15K SLoC