option-cell 0.1.0

OptionCell: OnceCell but derivable from Option
Documentation
  • Coverage
  • 100%
    11 out of 11 items documented1 out of 11 items with examples
  • Size
  • Source code size: 11.78 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.61 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • qnighy/option-cell
    4 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • qnighy

OptionCell: OnceCell but derivable from Option

This library provides an equivalent of OnceCell, but it guarantees layout compatibility with Option<T>, providing additional transmute helpers.

Known use-cases

  • Implementing the unification algorithm without exposing the interior mutability to the user or unnecessarily cloning the value.

Usage

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();

Development

Check with MIRI:

cargo +nightly miri test