Crates.io | generic_once_cell |
lib.rs | generic_once_cell |
version | 0.1.1 |
source | src |
created_at | 2022-11-10 13:54:55.674253 |
updated_at | 2022-12-15 10:43:26.546313 |
description | A bring-your-own-mutex version of once_cell. |
homepage | |
repository | https://github.com/mkroening/generic_once_cell |
max_upload_size | |
id | 712160 |
size | 46,072 |
generic_once_cell is a generic no_std
version of once_cell.
Internal synchronization for initialization is provided as type parameter via custom mutexes based on lock_api.
This makes it suitable for use in complex no_std
scenarios where once_cell's critical-section
support and once_cell::race
are not sufficient.
The core API looks roughly like this:
impl<R: lock_api::RawMutex, T> OnceCell<R, T> {
const fn new() -> Self { ... }
fn set(&self, value: T) -> Result<(), T> { ... }
fn get(&self) -> Option<&T> { ... }
}
More patterns and use-cases are in the docs!
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.