token_cell/lib.rs
1#![deny(
2 clippy::missing_panics_doc,
3 clippy::missing_const_for_fn,
4 clippy::missing_safety_doc,
5 clippy::missing_errors_doc,
6 missing_docs
7)]
8
9//! This library provides an alternative to [`ghost-cell`](https://crates.io/crates/ghost-cell) which uses concrete types instead of lifetimes for branding.
10//!
11//! This allows a more convenient usage, where cells and tokens can be constructed independently, with the same compile-time guarantees as [`ghost-cell`](https://crates.io/crates/ghost-cell). The trade-off for this arguably more convenient usage and arguably easier to understand branding method is that tokens, while zero-sized if made correctly, must be guaranteed to be constructable only if no other instance exists.
12#![cfg_attr(not(features = "std"), no_std)]
13pub use paste::paste;
14#[cfg(feature = "std")]
15mod std {
16 use crate::macros::{IdMismatch, SingletonUnavailable};
17 extern crate std;
18 impl std::error::Error for IdMismatch {}
19 impl std::error::Error for SingletonUnavailable {}
20}
21/// The basis for using `token_cell`
22pub mod prelude {
23 pub use crate::core::{TokenCell, TokenCellTrait, TokenTrait};
24}
25pub use crate::macros::token;
26/// The core aspects of `token_cell`
27pub mod core;
28/// A traitified version of `ghost_cell`.
29///
30/// To use this, simply construct a [`TokenCell`](crate::prelude::TokenCell) using a [`GhostToken`](crate::ghost::GhostToken) obtained with the [`TokenTrait::with_token`](crate::prelude::TokenTrait::with_token) constructor.
31pub mod ghost;
32/// The macros to construct tokens.
33pub mod macros;
34/// Because monads are cool.
35pub mod monads;
36
37runtime_token!(pub RuntimeToken);