Macros

Macros are basically code that generates other code. There are mainly 2 kinds of macros in rust:

  • Declarative macros
  • Procedural macros/Proc Macros

Jonhoo did a nice beginner friendly video on declarative macros on his channel here

Interesting macro patterns


#![allow(unused)]

fn main() {
#[macro_export]
macro_rules! my_macro {
    ($($expr:tt)*) => {
        $crate::MyStruct::myfunc(async move { $($expr)* }).await
    };
}

}