for my current needs, when I create a function I need to add it to a map(match function) and create a entry in dict.rs for that function.
file1.rs:-
fn login(data: Data) {} //a special function somewhere in middle of this file
file2.rs:-
fn register(data: Data) {} //another special function
dict.rs :-
//need to add entry for each special function with unique numbers
pub const LOGIN : u16 = 1
pub const REGISTER : u16 = 2
route.rs :-
use crate::dict;
// and then add it to the map
fn route_map(function){
match function {
dict::LOGIN => auth::login(route_data),
dict::REGISTER => auth::register(route_data),
_unknown => {}
}
}
I have to repeat this for all special functions and I believe this will soon get messy. is there any way I by pass all the code in route.rs and dict.rs and genrate at compile time by some macros ? something like Qt's moc compiler ?
something like this:-
#[CoolFn]
fn login() {}
and then other code is generated at compile time.
How can I achieve this ? if not I'm open to other possible solution to reduce the code