unique-type-id

A rust procedural macro crate for generating unique id for the rust types.

MIT licensed

What does it do?

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.

Usage

  1. Add unique-type-id as dependency in your Cargo.toml:

    toml [dependencies] unique-type-id-derive = "0.1" unique-type-id = "0.1"

  2. Create a struct or enum and use the trait:

    ```rust

    [macro_use]

    extern crate uniquetypeidderive; extern crate uniquetype_id;

    [test]

    fn sequentialsimple() { use uniquetype_id::{ SequentialTypeId }; #[derive(SequentialTypeId)] struct Test1; #[derive(SequentialTypeId)] struct Test2;

    asserteq!(Test1::id().0, 0u64); asserteq!(Test2::id().0, 1u64); } ```

License

This project is licensed under the MIT license.