Macros

This page is INCOMPLETE

This page is incomplete and is still being written.

Introduction

Macros are a way to write code that writes other code. The term macro refers to a family of features in Rust: declarative macros with macro_rules! and three kinds of procedural macros:

  • Custom #[derive] macros that specify code added with the derive attribute used on structs and enums
  • Attribute-like macros that define custom attributes usable on any item
  • Function-like macros that look like function calls but operate on the tokens specified as their argument

Declarative Macros

https://veykril.github.io/tlborm/decl-macros.html

Custom #[derive] Macros

https://github.com/dtolnay/proc-macro-workshop

Attribute-like Macros

https://github.com/dtolnay/proc-macro-workshop

Function-like Macros

https://github.com/dtolnay/proc-macro-workshop