Skip to content

Commit d6d1652

Browse files
dianneehuss
authored andcommitted
editorial tweaks
- Removes specification of `if let` guards' bindings "only" being valid if the guard succeeds. The arm body is only executed if the guard succeeds, so the bindings are always usable within the arm body when it's executed. - Makes terminology slightly more consistent (replaces some remaining uses of "`if let` guard" with "`let` pattern") - Other small wording and punctuation tweaks.
1 parent 53c2b7f commit d6d1652

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

src/expressions/match-expr.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,9 @@ r[expr.match.guard.let]
166166
Guards can use `let` patterns to conditionally match a scrutinee and to bind new variables into scope when the pattern matches successfully.
167167
168168
> [!EXAMPLE]
169-
> In this example, the guard condition `let Some(first_char) = name.chars().next()` is evaluated. If the `if let` expression successfully matches (i.e., the string has at least one character), the arm's body is executed with both `name` and `first_char` available. Otherwise, pattern matching continues to the next arm.
170-
>
171-
> The key point is that the `if let` guard creates a new binding (`first_char`) that's only available if the guard succeeds, and this binding can be used alongside the original pattern bindings (`name`) in the arm's body.
169+
> In this example, the guard condition `let Some(first_char) = name.chars().next()` is evaluated. If the `let` pattern successfully matches (i.e. the string has at least one character), the arm's body is executed. Otherwise, pattern matching continues to the next arm.
172170
>
171+
> The `let` pattern creates a new binding (`first_char`), which can be used alongside the original pattern bindings (`name`) in the arm's body.
173172
> ```rust
174173
> # enum Command {
175174
> # Run(String),

src/names/scopes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ r[names.scopes.pattern-bindings.let-chains]
4949
r[names.scopes.pattern-bindings.match-arm]
5050
* [`match` arms] bindings are within the [match guard] and the match arm expression.
5151
r[names.scopes.pattern-bindings.match-guard-let]
52-
* [`match` guard `let`] bindings are valid in the following guard conditions and the match arm expression if the guard succeeds.
52+
* [`match` guard `let`] bindings are valid in the following guard conditions and the match arm expression.
5353

5454
r[names.scopes.pattern-bindings.items]
5555
Local variable scopes do not extend into item declarations.

0 commit comments

Comments
 (0)