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

#1307 in Rust patterns

Download history 52/week @ 2024-07-30 9/week @ 2024-09-24 5/week @ 2024-10-01

70 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