This library provides an equivalent of OnceCell, but it guarantees layout compatibility with Option<T>
, providing additional transmute helpers.
- Implementing the unification algorithm without exposing the interior mutability to the user or unnecessarily cloning the value.
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