6 releases

0.1.4 Dec 26, 2018
0.1.3 Dec 9, 2018
0.1.2 Nov 11, 2018
0.1.0 Oct 27, 2018
0.0.0 Oct 22, 2018

#496 in Data structures

Download history 74/week @ 2020-07-24 38/week @ 2020-07-31 67/week @ 2020-08-07 64/week @ 2020-08-14 87/week @ 2020-08-21 84/week @ 2020-08-28 73/week @ 2020-09-04 100/week @ 2020-09-11 20/week @ 2020-09-18 52/week @ 2020-09-25 74/week @ 2020-10-02 52/week @ 2020-10-09 73/week @ 2020-10-16 79/week @ 2020-10-23 91/week @ 2020-10-30 94/week @ 2020-11-06

281 downloads per month
Used in 2 crates


131 lines

pipeline crates.io Docs rustc


uid (short for unique identifiers) is a crate for creating unique IDs for usage in a Rust program. IDs can have many purposes in programs, but this crate's IDs are mostly useful for identification tasks. For example, consider having some form of simple in-memory database (in the form of a HashMap or something more sophisticated). IDs as created by this crate make for perfect primary keys.

Said IDs have a couple properties that, depending on the context, are useful to have:

  1. IDs are lightweight and ultimately just a number with some compile time magic (and a small creation cost) attached to them.
  2. Created IDs are guaranteed to be unique. That is, when created at runtime (deserialization is not supported for obvious reasons), two newly crated IDs are guaranteed to never be the same.
  3. They are fully thread safe. That is, uniqueness is guaranteed even among different threads.
  4. IDs are immutable. Once created, an ID can be copied, hashed, compared, and more, but it cannot be changed.
  5. IDs can form name (or rather type) spaces. That is, an ID can be parametrized by an arbitrary (potentially private) type and only IDs that are parametrized by the same type can interact (i.e., be compared etc.).

No runtime deps