#typeid #type #key #closures #type-id #1

type-key

Unique type identifier for any non-static type

2 releases (1 stable)

1.0.0 Jun 22, 2023
0.1.0 Jun 22, 2023

#6 in #typeid

40 downloads per month
Used in 2 crates (via fn-store)

MIT license

3KB

TypeKey

Unique type identifier for any non-static type (unlike core::any::Any)

Usage

use type_key::TypeKey;

let a = 1;
let closure = || &a;

let key = TypeKey::of_val(&closure);

Implementation detail

The TypeKey wraps TypeId of closure in TypeKey::of. Since the closure captures its environment, the returned TypeId is unique for each type.

License

MIT

No runtime deps