[Verse 1] When you need to write the same code again and again There's a better way my friend, let me show you when Macros are like templates that expand your code for you Write it once and let it grow, that's what smart coders do [Chorus] Macro magic, exclamation mark Generate code right from the start Println macro, vec macro too Bang that symbol, let Rust work for you Macro magic, compile time friend Write less code that won't break or bend [Verse 2] See that exclamation point after println there That's how Rust knows it's a macro, handle it with care Not a function call you see, it's code that writes more code At compile time it expands out, lightening up your load [Chorus] Macro magic, exclamation mark Generate code right from the start Println macro, vec macro too Bang that symbol, let Rust work for you Macro magic, compile time friend Write less code that won't break or bend [Bridge] Declarative rules or procedural ways Pattern matching through your coding days Macro rules with arms that catch your call Generate the code to handle them all [Verse 3] Vec macro builds your vectors fast and clean Just list your elements, no push routine Format strings in println work their charm Curly braces hold your values safe from harm [Chorus] Macro magic, exclamation mark Generate code right from the start Println macro, vec macro too Bang that symbol, let Rust work for you Macro magic, compile time friend Write less code that won't break or bend [Outro] When you see that bang symbol, you know what's true Macros working hard for you Code generation, that's the way Rust macros save your coding day
← Interior mutability (RefCell, Mutex) | Shared state concurrency →