sloth
This crate provides a generic pointer-like Lazy<T, Eval> struct for lazily initialized values.
It can be used for expensive-to-calculate values to ensure that the evaluation logic runs
only once and only if needed.
For example:
use Lazy;
let lazy_string = new;
let lazy_number = new;
//...
let must_use_string = true;
//...
if must_use_string else
The evaluated value of a mutable Lazy can be modified:
use Lazy;
let mut lazy_vec = new;
lazy_vec.retain;
assert_eq!;
Lazy can be consumed and turned into its value via unwrap():
use Lazy;
let lazy_value = new;
let output = Stringfrom + lazy_value.unwrap;