rust-lang / rust-lang/rust-by-example

Chapter 17.3 DSL: Curly braces in macro invocation

Open
#1,956 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Handlebars
Stars
8.1k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

in this code snippet

macro_rules! calculate {
    (eval $e:expr) => {
        {
            let val: usize = $e; // Force types to be unsigned integers
            println!("{} = {}", stringify!{$e}, val);
        }
    };
}

what is the implication of using curly braces with stringify! ? Looks like those do not change program behaviour in any way, compared to normal parentheses.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Chapter 17.3 and the shown macro_rules! example, focusing on the stringify! invocation and its curly braces. Verify whether curly braces and parentheses differ in this context, then clarify the chapter so the delimiter behavior and any effect on the program are explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.