A rust procedural macro crate for generating unique id for the rust types.
It simply implements a trait for the type where is only one method - id() -> TypeId
which returns a unique positive number. Unique in the whole project, but not everywhere else.
Add unique-type-id
as dependency in your Cargo.toml
:
toml
[dependencies]
unique-type-id-derive = "0.1"
unique-type-id = "0.1"
Create a struct or enum and use the trait:
```rust
extern crate uniquetypeidderive; extern crate uniquetype_id;
fn sequentialsimple() { use uniquetype_id::{ SequentialTypeId }; #[derive(SequentialTypeId)] struct Test1; #[derive(SequentialTypeId)] struct Test2;
asserteq!(Test1::id().0, 0u64); asserteq!(Test2::id().0, 1u64); } ```
This project is licensed under the MIT license.