Open vincenzopalazzo opened 1 year ago
quote is a great example of how we can use procedural macros to write code, and I would like to make some experiments to make something similar, but simpler that reflects the way that we format a string. Currently, we can do with kparser
let code = format!( "impl{} {}{} {{ \ fn get_{}(&self) -> {} {{ \ return self.{}.clone()\ }}\ }}", gen, name, gen, attributes[0].name, attributes[0].ty, attributes[0].name, );
The idea is to use procedural macros that write this format for us, like:
editor! { impl ${gen} ${name}${gen} { fn get_${attributes[0].name}(&self) -> ${attributes[0].ty} { return self.${attributes[0].name}.clone() } } }
this is more Makefile syntax and you can inject commands like:
editor!{ @foreach ${attributes} { println!("{}", ${ir}); } }
we should look also at the quote present in the nightly version https://doc.rust-lang.org/proc_macro/fn.quote.html
quote is a great example of how we can use procedural macros to write code, and I would like to make some experiments to make something similar, but simpler that reflects the way that we format a string. Currently, we can do with kparser
The idea is to use procedural macros that write this format for us, like:
this is more Makefile syntax and you can inject commands like: