rust-lang / rust-lang/reference

Nomenclature question: what is the `EXPR` in `for PATTERN in EXPR { }` called?

Open
#1,841 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

Location

https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops

Context

I was reviewing a test cleanup PR https://github.com/rust-lang/rust/pull/141974, and I was trying to say something about the EXPR in

for PATTERN in EXPR {
    //         ^--- what is this expr called?
    // ...
}

but I couldn't find a good term for this[^1][^2]. The current grammar calls this EXPR

Expressionexcept struct expression

whereas for e.g. match EXPR { .. } or if let PATTERN = EXPR { .. }, there's a more "meaningful name" for that EXPR, which is the scrutinee expr.

[^1]: In the community discord, terms like "interatee" or "iterable" or "into-iterable" were suggested, but yeah.
[^2]: Nadrieril came up with "loopee", which is an excellent term 😆

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 the iterator-loops section of the Rust Reference at the linked location, then compare its EXPR wording with the scrutinee terminology used for match and if let. The work is done when the project has agreed on a term for the expression and the relevant reference wording reflects that decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.