#set #defer #initialized #value #struct #deferred #box

deferred-box

Defer the value set after the struct has been initialized

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

#1615 in Rust patterns

Download history 289/week @ 2024-10-31 55/week @ 2024-11-07 107/week @ 2024-11-14 82/week @ 2024-11-21 18/week @ 2024-11-28 72/week @ 2024-12-05 56/week @ 2024-12-12 3/week @ 2024-12-19

131 downloads per month
Used in 5 crates (2 directly)

MIT license

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

No runtime deps