Crate ghost_cell[−][src]
This library provides an implementation of GhostCell
and its GhostToken
:
The implementation is based on http://plv.mpi-sws.org/rustbelt/ghostcell/.
Safety
http://plv.mpi-sws.org/rustbelt/ghostcell/ left some blanks in the implementation of GhostCell
and GhostToken
that I have filled in myself. I hopefully didn’t make a mistake, hopefully.
Use at your own risk!
Example
A simple self-contained example:
use ghost_cell::{GhostToken, GhostCell}; fn demo(n: usize) { let value = GhostToken::new(|mut token| { let cell = GhostCell::new(42); let vec: Vec<_> = (0..n).map(|_| &cell).collect(); *vec[n / 2].borrow_mut(&mut token) = 33; *cell.borrow(&token) }); assert_eq!(value, 33); }
Structs
GhostCell | Branded wrapper for the data structure’s nodes, whose type is T. |
GhostToken | A single “branded” permission to access the data structure. Implemented with a phantom-lifetime marker type. |