I wrote this code:
//Amazing log function that can take up to three parameters!!!
macro_rules! log {
// todo variadic
() => {
let string = " ";
info!(" ");
};
($a:expr) => {
let string = format!("{}", format_args!("{}", $a));
info!("{}", string);
};
($a:expr,$b:expr) => {
let string = format!("{}", format_args!("{}{}", $a, $b));
info!("{}", string);
};
($a:expr,$b:expr,$c:expr) => {
let string = format!("{}", format_args!("{}{}{}", $a, $b, $c));
info!("{}", string);
};
}
Example usage:
let number = 163.19;
log!("Heeey fam is this number right: ", number, ". No, it's wrong");
//output: [TIME INFO project] Hey fam is this number correct: 163.19. No, it's wrong
I want it to be able to take any number of parameters is that possible in rust?