#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

#192 in Procedural macros

Download history 3187/week @ 2023-12-06 2874/week @ 2023-12-13 2341/week @ 2023-12-20 1712/week @ 2023-12-27 4783/week @ 2024-01-03 3419/week @ 2024-01-10 3645/week @ 2024-01-17 4114/week @ 2024-01-24 5174/week @ 2024-01-31 5294/week @ 2024-02-07 4991/week @ 2024-02-14 4557/week @ 2024-02-21 4253/week @ 2024-02-28 5050/week @ 2024-03-06 4622/week @ 2024-03-13 3974/week @ 2024-03-20

18,820 downloads per month
Used in 54 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
~21K SLoC