rust-lang / rust-lang/rust-by-example
Chapter 17.2: undescribed repetition pattern?
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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