Expand description
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);
Structs§
Enums§
- Value
OrSetter - Indicates the value or needs to set the value.