4 stable releases

1.1.1 Oct 17, 2021
1.1.0 Jul 15, 2020
1.0.1 Nov 23, 2019

#45 in #unique-identifier

Download history 205/week @ 2024-06-03 344/week @ 2024-06-10 228/week @ 2024-06-17 205/week @ 2024-06-24 143/week @ 2024-07-08 279/week @ 2024-07-15 154/week @ 2024-07-22 188/week @ 2024-07-29 204/week @ 2024-08-05 214/week @ 2024-08-12 144/week @ 2024-08-19 329/week @ 2024-08-26 87/week @ 2024-09-02 201/week @ 2024-09-09 139/week @ 2024-09-16

797 downloads per month
Used in 84 crates (10 directly)

MIT license

6KB
133 lines

TypId

Typed Unique Identifier gives you ability to create and use identifiers bound to specified type.

Installation

Cargo.toml

[dependencies]
typid = "1"

Example

use typid::ID;

struct Foo {
    pub id: ID<Foo>,
}

fn main() {
    let a = Foo { id: ID::new() };
    let b = Foo { id: ID::new() };
    assert_ne!(a.id, b.id);
}

lib.rs:

Typed Unique Identifier gives you ability to create and use identifiers bound to specified type.

Typical usage example:

use typid::ID;

struct Foo {
    pub id: ID<Foo>,
}

let a = Foo { id: ID::new() };
let b = Foo { id: ID::new() };
assert_ne!(a.id, b.id);

Dependencies

~0.7–1.6MB
~32K SLoC