21
Macros
Never limit yourself because of others’ limited imagination.
— Mae Jemison
The use of macros allows you to reimagine Rust within the context of your own aspirations. Rust’s support of macros is a powerful feature that provides almost unlimited capabilities. You can provide new features, implement default behavior, or simply avoid redundancy.
The println! macro is probably the most well-known macro in the Rust universe. It provides the capability of a variadic function. This is because Rust does not support variadic functions. Therefore, the println! macro provides a feature not available in the standard language. A close second in popularity is the derive attribute. The derive attribute for the Clone and Copy traits, for example, is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access