#trait #singleton #experimental #ghost #proof

no-std singleton-trait

Singleton trait for types with unique values and Erased type for zero-sized ownership proofs

6 releases (3 breaking)

0.4.0 May 7, 2022
0.3.0 Aug 28, 2021
0.2.0 Jul 29, 2021
0.1.2 Jul 18, 2021

#525 in Rust patterns

27 downloads per month
Used in singleton-cell

MIT license

174 lines

Version 0.4.0 MIT License

This library provides simple unsafe traits for types with global uniqueness properties, as well as the Erased class for proofs. This crate does not provide implementation strategies, but does provide several examples of valid implementers.

Primarily, it is intended to be used for ghost proofs, in which ownership of a value of particular type is sufficient in order for other safety conditions.

The type Erased<T> and the trait Exists<T> are additionally provided as zero-sized proofs of ownership of a type (including references) when existence is enough for safety.

No runtime deps