Skip to content

Commit 9add291

Browse files
committed
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 7cedaea commit 9add291

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/expressions/match-expr.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ r[expr.match.guard.let]
173173
Guards can use `let` patterns to conditionally match a scrutinee and to bind new variables into scope when the pattern matches successfully.
174174
175175
> [!EXAMPLE]
176-
> 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.
176+
> 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.
177177
>
178-
> 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.
178+
> The `let` pattern creates a new binding (`first_char`), which can be used alongside the original pattern bindings (`name`) in the arm's body.
179179
> ```rust
180180
> # enum Command {
181181
> # Run(String),

src/names/scopes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ r[names.scopes.pattern-bindings.let-chains]
5555
r[names.scopes.pattern-bindings.match-arm]
5656
* [`match` arms] bindings are within the [match guard] and the match arm expression.
5757
r[names.scopes.pattern-bindings.match-guard-let]
58-
* [`match` guard `let`] bindings are valid in the following guard conditions and the match arm expression if the guard succeeds.
58+
* [`match` guard `let`] bindings are valid in the following guard conditions and the match arm expression.
5959

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

0 commit comments

Comments
 (0)