generic_once_cell

Crates.iogeneric_once_cell
lib.rsgeneric_once_cell
version0.1.1
sourcesrc
created_at2022-11-10 13:54:55.674253
updated_at2022-12-15 10:43:26.546313
descriptionA bring-your-own-mutex version of once_cell.
homepage
repositoryhttps://github.com/mkroening/generic_once_cell
max_upload_size
id712160
size46,072
Martin Kröning (mkroening)

documentation

README

generic_once_cell

Crates.io docs.rs CI

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!

License

Licensed under either of

at your option.

Contribution

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.

Commit count: 10

cargo fmt