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

Chapter 17.2: undescribed repetition pattern?

Open
#1,955 0 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

Code example in chapter 17.2 has the following macro defined:

macro_rules! assert_equal_len {
    // The `tt` (token tree) designator is used for
    // operators and tokens.
    ($a:expr, $b:expr, $func:ident, $op:tt) => {
        assert!($a.len() == $b.len(),
                "{:?}: dimension mismatch: {:?} {:?} {:?}",
                stringify!($func),
                ($a.len(),),
                stringify!($op),
                ($b.len(),));
    };
}

It is unclear why $a.len() and $b.len() are wrapped in parentheses with a trailing comma inside after the expression - looks like it could mean multiple instances (or lack) of an expression, but the context does not seem to allow for that. What is the purpose of that syntax?

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 by reading chapter 17.2 around the assert_equal_len! macro and its surrounding explanation. Clarify the purpose of the parenthesized expressions with trailing commas, and consider the issue done when a reader can understand that syntax from the chapter text.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.