#uuid #unique-identifier #proc-macro

macro gensym

Creates unique identifiers for macros using procedural macros

2 releases

0.1.1 Aug 5, 2023
0.1.0 Jan 19, 2019

#284 in Procedural macros

Download history 6888/week @ 2024-07-19 6911/week @ 2024-07-26 5695/week @ 2024-08-02 4989/week @ 2024-08-09 5506/week @ 2024-08-16 5498/week @ 2024-08-23 5563/week @ 2024-08-30 4806/week @ 2024-09-06 4556/week @ 2024-09-13 4726/week @ 2024-09-20 3213/week @ 2024-09-27 5724/week @ 2024-10-04 4195/week @ 2024-10-11 4612/week @ 2024-10-18 4796/week @ 2024-10-25 5690/week @ 2024-11-01

20,502 downloads per month
Used in 76 crates (12 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.4–1MB
~20K SLoC