2 releases

0.3.1 Jan 12, 2024
0.3.0 Jan 2, 2024
0.2.1 Dec 29, 2023
0.1.3 Dec 30, 2023

#1861 in Rust patterns

Download history 9/week @ 2024-01-01 14/week @ 2024-01-08 2/week @ 2024-01-22 19/week @ 2024-02-26 26/week @ 2024-04-01 147/week @ 2024-04-15

173 downloads per month
Used in toast-cell

Unlicense

7KB
112 lines

type-factory

Generates unique values of opaque types.


lib.rs:

type_factory

Generates unique values of opaque types.

Usage

with(|initial/*: Initial<'_> */| {
    let (a, b) = split(initial);
    let (b, c) = split(b);
    // `a`, `b`, and `c` are each of a distinct `impl '_ + Unique` type.
});

impl [Unique] values are guaranteed to be unique. They cannot be copied or cloned and are suitable for use as brand types.

The toast-cell crate utilizes this property.

Minimum supported Rust version

The MSRV is currently 1.56.

This may change between minor releases.

License

I release this crate into the public domain using the Unlicense.

Similar crates

generativity provides a macro to generate unique invariant lifetimes. It does not require dependent code to reside within a closure.

No runtime deps