Crates.io | option-cell |
lib.rs | option-cell |
version | 0.1.0 |
source | src |
created_at | 2023-09-10 06:09:43.707531 |
updated_at | 2023-09-10 06:09:43.707531 |
description | OptionCell: OnceCell but derivable from Option |
homepage | |
repository | https://github.com/qnighy/option-cell |
max_upload_size | |
id | 968621 |
size | 12,108 |
This library provides an equivalent of OnceCell, but it guarantees layout compatibility with Option<T>
, providing additional transmute helpers.
cargo add option-cell
use option_cell::OptionCell;
let mut options = vec![None, None];
let cells = OptionCell::from_mut_slice(&mut options);
cells[0].set(1).unwrap();
Check with MIRI:
cargo +nightly miri test