2 releases

0.1.1 Aug 5, 2023
0.1.0 Jan 19, 2019

#582 in Procedural macros

Download history 6377/week @ 2025-12-25 9483/week @ 2026-01-01 11794/week @ 2026-01-08 9725/week @ 2026-01-15 8778/week @ 2026-01-22 9673/week @ 2026-01-29 9547/week @ 2026-02-05 12017/week @ 2026-02-12 15107/week @ 2026-02-19 16377/week @ 2026-02-26 19254/week @ 2026-03-05 15847/week @ 2026-03-12 14609/week @ 2026-03-19 11870/week @ 2026-03-26 10499/week @ 2026-04-02 13427/week @ 2026-04-09

52,827 downloads per month
Used in 141 crates (13 directly)

MIT/Apache

8KB

Creates unique identifiers for macros using procedural macros and UUID

Examples


macro_rules! gen_fn {
    ($a:ty, $b:ty) => {
        gensym::gensym!{ _gen_fn!{ $a, $b } }
    };
}

macro_rules! _gen_fn {
    ($gensym:ident, $a:ty, $b:ty) => {
        fn $gensym(a: $a, b: $b) {
            unimplemented!()
        }
    };
}

mod test {
    gen_fn!{ u64, u64 }
    gen_fn!{ u64, u64 }
}

Generate a unique identifier with a span of Span::call_site and insert it as the first argument to a macro call followed by a comma.


Crates.io Rust Documentation

gensym

Creates unique identifiers for macros using procedural macros and UUID

Examples


macro_rules! gen_fn {
    ($a:ty, $b:ty) => {
        gensym::gensym!{ _gen_fn!{ $a, $b } }
    };
}

macro_rules! _gen_fn {
    ($gensym:ident, $a:ty, $b:ty) => {
        fn $gensym(a: $a, b: $b) {
            unimplemented!()
        }
    };
}

mod test {
    gen_fn!{ u64, u64 }
    gen_fn!{ u64, u64 }
}

Dependencies

~315–720KB
~15K SLoC