1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! 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:
//!
//! ```rust
//! 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);
//! }
//! ```

//  Generic features.
#![cfg_attr(not(test), no_std)]

//  Lints.
#![deny(missing_docs)]

mod ghost_cell;

pub use self::ghost_cell::{GhostCell, GhostToken};

#[cfg(feature = "experimental-ghost-cursor")]
mod ghost_cursor;

#[cfg(feature = "experimental-ghost-cursor")]
pub use self::ghost_cursor::GhostCursor;