Macros

Learn to use metaprogramming in Rust.

Introduction to macros

Macros are the Rust metaprogramming feature that creates code in compile-time. Through this, we can save duplication, but we need to be careful because we could make a mess.

Macros are called using a ! in the end. We’ve been using a macro called println! to print text to the standard output.

Get hands-on with 1400+ tech skills courses.