Skip to content

Commit 614c19c

Browse files
authored
Merge pull request #4122 from rust-lang/fix-inverted-shadowing
Fix more inverted uses of “shadowed”
2 parents 810d8ed + b2e71e8 commit 614c19c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ch19-01-all-the-places-for-patterns.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ background color`.
8484

8585
You can see that `if let` can also introduce new variables which shadow existing
8686
variables in the same way that `match` arms can: the line `if let Ok(age) = age`
87-
introduces a new shadowed `age` variable that contains the value inside the `Ok`
88-
variant. This means we need to place the `if age > 30` condition within that
89-
block: we can’t combine these two conditions into `if let Ok(age) = age && age >
90-
30`. The shadowed `age` we want to compare to 30 isn’t valid until the new scope
91-
starts with the curly bracket.
87+
introduces a new `age` variable that contains the value inside the `Ok` variant,
88+
shadowing the existing `age` variable. This means we need to place the `if age >
89+
30` condition within that block: we can’t combine these two conditions into `if
90+
let Ok(age) = age && age > 30`. The new `age` we want to compare to 30 isn’t
91+
valid until the new scope starts with the curly bracket.
9292

9393
The downside of using `if let` expressions is that the compiler doesn’t check
9494
for exhaustiveness, whereas with `match` expressions it does. If we omitted the

0 commit comments

Comments
 (0)