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: about 1 year ago
JSON representation
Unique type identifier for any non-static type (unlike `core::any::Any`)
- Host: GitHub
- URL: https://github.com/storycraft/type-key
- Owner: storycraft
- License: mit
- Created: 2023-06-22T07:31:45.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-22T03:12:09.000Z (almost 3 years ago)
- Last Synced: 2025-06-09T09:03:04.891Z (about 1 year ago)
- Topics: any, rust, typeid
- Language: Rust
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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