Crates.io | deferred-box |
lib.rs | deferred-box |
version | 0.1.4 |
source | src |
created_at | 2024-11-03 07:05:56.234208 |
updated_at | 2024-11-03 07:51:26.012703 |
description | Defer the value set after the struct has been initialized |
homepage | |
repository | https://github.com/victorteokw/deferred-box |
max_upload_size | |
id | 1433433 |
size | 4,797 |
Defer the value set after the struct has been initialized.
Add these lines to Cargo.toml
under the [dependencies]
section:
deferred-box = "0.1"
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
MIT License