| Crates.io | critical-once-cell |
| lib.rs | critical-once-cell |
| version | 0.2.0 |
| created_at | 2022-04-20 12:30:05.307763+00 |
| updated_at | 2025-02-13 07:27:34.125674+00 |
| description | Thread-safe OnceCell and Lazy backed by critical section |
| homepage | |
| repository | https://github.com/rustne-kretser/critical-once-cell |
| max_upload_size | |
| id | 570950 |
| size | 14,850 |
Drop-in replacements for [core::lazy::OnceCell] and
[core::lazy::Lazy], backed by [critical_section].
CriticalOnceCelluse critical_once_cell::CriticalOnceCell;
static CELL: CriticalOnceCell<String> = CriticalOnceCell::new();
fn main() {
CELL.set("Hello, World!".to_owned()).unwrap();
assert_eq!(*CELL.get().unwrap(), "Hello, World!");
}
CriticalLazyuse critical_once_cell::CriticalLazy;
static LAZY: CriticalLazy<String> = CriticalLazy::new(|| "Hello, World!".to_owned());
fn main() {
assert_eq!(*LAZY, "Hello, World!");
}
For more details, see docs.
Add this to your Cargo.toml:
[dependencies]
critical-once-cell = "0.2.0"
MPL-2.0