Crate ghost_cell[][src]

This library provides an implementation of GhostCell and its GhostToken:

The implementation is based on

Safety 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!


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;


    assert_eq!(value, 33);



Branded wrapper for the data structure’s nodes, whose type is T.


A single “branded” permission to access the data structure. Implemented with a phantom-lifetime marker type.