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` as per //! http://plv.mpi-sws.org/rustbelt/ghostcell/ as well as some extensions. //! //! # Safety //! //! The actual implementation of `GhostCell` is found at https://gitlab.mpi-sws.org/FP/ghostcell/-/tree/master/ghostcell //! and has been proven safe. I have carefully checked that this implementation faithfully reproduces the safety //! guarantees. //! //! Extensions to `GhostCell`, such as `GhostCursor`, are not proven, neither at the design nor implementation level. //! As such, they are only available if the appropriate Cargo features are enabled. //! //! # Example //! //! A simple self-contained example: //! //! ```rust //! use ghost_cell::{GhostToken, GhostCell}; //! //! let n = 42; //! //! 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!(33, value); //! ``` // Generic features. #![cfg_attr(not(test), no_std)] // Lints. #![deny(missing_docs)] pub mod ghost_cell; pub use self::ghost_cell::{GhostCell, GhostToken}; #[cfg(feature = "experimental-ghost-cursor")] pub mod ghost_cursor; #[cfg(feature = "experimental-ghost-cursor")] pub use self::ghost_cursor::GhostCursor;