Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/storycraft/type-key

Unique type identifier for any non-static type (unlike `core::any::Any`)
https://github.com/storycraft/type-key

any rust typeid

Last synced: 15 days ago
JSON representation

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

Awesome Lists containing this project

README

        

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

## Usage
```rust
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.

For more explanation about closure lifetime, see: https://github.com/rust-lang/rust/issues/27086

## License
MIT