Swarnim Arun


Et tu `macro_rules!`

Submitted Feb 7, 2023

Using declarative macros(as in macro_rules!) can be challenging, and knowing when to use them is perhaps even harder. So let’s take some real-world examples and discuss how you can use rust macros to write your mini-DSLs for simplifying a lot of the boilerplate Rust might force upon you.

While discussing writing a simple library using macros, we shall take a tour of the popular design patterns for writing robust hygienic macros and figure out the best places to use them in Rust. And also perhaps understand the desire for macros_2.0.

We will take a gander at their limitations and the cases where you perhaps should avoid them.
Maybe even discuss how you can use them to make your async code less verbose. (no promises though :P)

Swarnim Arun
Rust Engineer @ DeepSource


{{ gettext('Login to leave a comment') }}

{{ gettext('Post a comment…') }}
{{ gettext('New comment') }}
{{ formTitle }}

{{ errorMsg }}

{{ gettext('No comments posted yet') }}

Hosted by

A community of rust-lang contributors and end-users from Bangalore. We also have presence on the following telegram channels https://t.me/RustIndia https://t.me/keralars https://t.me/fpncr Twitter handle: https://twitter.com/rustlangin more