Expand description
§type_factory
Generates unique values of opaque types.
§How does it work?
Using return-position impl Trait in traits (RPITIT), we can repeatedly
create new opaque types out of previous ones.
let a = type_factory::try_init().unwrap();
let (a, b) = a.split();
let (b, c) = b.split();
// `a`, `b`, and `c` are each of a distinct `impl Unique` type.Each impl Unique value is entirely unique and cannot be
copied or cloned. Therefore, their primary use would be as brands.
The toast-cell crate utilizes this property.
§Minimum supported Rust version
The MSRV is currently 1.75.
This may change between minor versions.
§Similar crates
generativityprovides a way to create unique invariant lifetimes, which may also be used as brands. However, it comes with a few drawbacks related to the method of creating these lifetimes.unique-typeis nightly-only and uses unstable features to generate unique types in a similar fashion to this crate. However, it is intended to create unconstructable unique types that exist only on the type level, while this crate is for constructing unique types on the value level.
Traits§
- Unique
- Implemented for unique types.