#unique-identifier #proc-macro #create #procedural #uuid

macro gensym

Creates unique identifiers for macros using procedural macros

2 releases

0.1.1 Aug 5, 2023
0.1.0 Jan 19, 2019

#213 in Procedural macros

Download history 4350/week @ 2024-01-05 3355/week @ 2024-01-12 4131/week @ 2024-01-19 4407/week @ 2024-01-26 5629/week @ 2024-02-02 4616/week @ 2024-02-09 4811/week @ 2024-02-16 4967/week @ 2024-02-23 4219/week @ 2024-03-01 4657/week @ 2024-03-08 4979/week @ 2024-03-15 4489/week @ 2024-03-22 4147/week @ 2024-03-29 3412/week @ 2024-04-05 5709/week @ 2024-04-12 3749/week @ 2024-04-19

17,988 downloads per month
Used in 55 crates (7 directly)

MIT/Apache

8KB

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 }
}

lib.rs:

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.

Dependencies

~0.5–1MB
~22K SLoC