5 releases
0.1.4 | Nov 3, 2024 |
---|---|
0.1.3 | Nov 3, 2024 |
0.1.2 | Nov 3, 2024 |
0.1.1 | Nov 3, 2024 |
0.1.0 | Nov 3, 2024 |
#1327 in Rust patterns
519 downloads per month
Used in 5 crates
(via teo-runtime)
5KB
93 lines
Deferred Box
Defer the value set after the struct has been initialized.
Installation
Add these lines to Cargo.toml
under the [dependencies]
section:
deferred-box = "0.1"
Usage
let deferred_box = DeferredBox::new();
deferred_box.get(); // None
deferred_box.set(42);
deferred_box.get(); // Some(&42)
deferred_box.get_or_init(|| 0); // &42
License
MIT License