Crates.io | global-id-creator-macro |
lib.rs | global-id-creator-macro |
version | 0.1.1 |
source | src |
created_at | 2024-09-29 19:16:33.408666 |
updated_at | 2024-11-17 15:41:24.150002 |
description | A procedural macro library for generating constants |
homepage | |
repository | |
max_upload_size | |
id | 1391087 |
size | 5,254 |
use global_id_creator_macro::ntl_create_global_id;
pub enum Global {
Id(u8)
}
ntl_create_global_id!(Global, CONST_A, CONST_B, CONST_C, CONST_D, CONST_E);
fn main() {
println!("CONST_A = {:?}", CONST_A);
println!("CONST_B = {:?}", CONST_B);
println!("CONST_C = {:?}", CONST_C);
println!("CONST_D = {:?}", CONST_D);
println!("CONST_E = {:?}", CONST_E);
}
output:
CONST_A = Id(100)
CONST_B = Id(101)
CONST_C = Id(102)
CONST_D = Id(103)
CONST_E = Id(104)
the macro will be expanded like this:
pub const CONST_A: Global = Global::Id(100);
pub const CONST_A: Global = Global::Id(101);
pub const CONST_A: Global = Global::Id(102);
pub const CONST_A: Global = Global::Id(103);
pub const CONST_A: Global = Global::Id(104);
This crate is just use for my personal project, so it maybe not fit which your need