[][src]Crate lazy_futuristic

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

Lazy

Lazy variable.

Setter

Setter of Lazy objects which also acts as Mutex guard.

Enums

ValueOrSetter

Indicates the value or needs to set the value.