uniqify

Crates.iouniqify
lib.rsuniqify
version0.1.0
created_at2025-09-24 23:10:28.116695+00
updated_at2025-09-24 23:10:28.116695+00
descriptionCompile-time unique IDs for Rust, a `__COUNTER__`-like macro, safe and simple
homepage
repositoryhttps://git.gay/vi/uniqify
max_upload_size
id1853911
size7,319
Sumire (ImSumire)

documentation

README

uniqify

License Crates.io Downloads

A Rust equivalent of the C macro __COUNTER__, generating unique integers at compile time.

Features

  • Generates unique and deterministic usize at each call
  • Works at comptime thanks to a procedural macro
  • Not 100% safe (has not been widely tested and debugged) but simple to use shrug

Installation

cargo add uniqify

Usage

use uniqify::uniqify;

fn main() {
    let a = uniqify!();
    let b = uniqify!();
    let c = uniqify!();

    println!("{a}, {b}, {c}");
}

Expected result

0, 1, 2

Notes

If there are any issues, I will try to resolve them, but I must admit that I am not very good with macros and that, for me, it is still a bit of a miracle.

Commit count: 0

cargo fmt