Macro tylisp::uuid_new_v4[][src]

uuid_new_v4!() { /* proc-macro */ }
Expand description

Construct a new random UUID

This macro constructs a new random (v4) UUID at compile time and returns it as a typenum::Unsigned type. Tis can be used to enable the type system to perform a limited form of negative reasoning on type identities.

For example:

#![recursion_limit = "256"]
use typenum::{Unsigned,IsEqual,True,False};
use typenum_uuid::uuid_new_v4;

trait Id { type ID: typenum::Unsigned; }

trait Different<B:Id> {}
impl<A:Id, B:Id> Different<B> for A
    where A::ID: IsEqual<B::ID, Output=False> {}

struct T1;
impl Id for T1 { type ID = uuid_new_v4!(); }

struct T2;
impl Id for T2 { type ID = uuid_new_v4!(); }

fn must_be_different<A:Id, B:Id + Different<A>>(a:A, b:B) {};

must_be_different(T1, T2);
// must_be_different(T1, T1);  // Compile Error