Skip to content

Commit d7a1dba

Browse files
committed
Add note about feature-gate
Also fix a couple of typos.
1 parent 6eeedc1 commit d7a1dba

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

active/0000-if-let.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The motivation for having any construct at all for this is to simplify the cases
2323
a `match` statement with a single non-trivial case. This is predominately used for unwrapping
2424
`Option<T>` values, but can be used elsewhere.
2525

26-
The idiomatic solution today for testing and unwrawpping an `Option<T>` looks like
26+
The idiomatic solution today for testing and unwrapping an `Option<T>` looks like
2727

2828
```rust
2929
match optVal {
@@ -51,7 +51,7 @@ This is generally considered to be a less idiomatic solution than the `match`. I
5151
fixing rightward drift, but it ends up testing the value twice (which should be optimized away, but
5252
semantically speaking still happens), with the second test being a method that potentially
5353
introduces failure. From context, the failure won't happen, but it still imposes a semantic burden
54-
on the reader. Finally, it requies having a pre-existing let-binding for the optional value; if the
54+
on the reader. Finally, it requires having a pre-existing let-binding for the optional value; if the
5555
value is a temporary, then a new let-binding in the parent scope is required in order to be able to
5656
test and unwrap in two separate expressions.
5757

@@ -67,7 +67,7 @@ if let Some(x) = optVal {
6767

6868
The `if let` construct is based on the precedent set by Swift, which introduced its own `if let`
6969
statement. In Swift, `if let var = expr { ... }` is directly tied to the notion of optional values,
70-
and unwraps the optional value that `expr` evalutes to. In this proposal, the equivalent is `if let
70+
and unwraps the optional value that `expr` evaluates to. In this proposal, the equivalent is `if let
7171
Some(var) = expr { ... }`.
7272

7373
Given the following rough grammar for an `if` condition:
@@ -100,6 +100,10 @@ Optionally, one or more `else if` (not `else if let`) blocks can be placed in th
100100
pattern guards on `_`. This could be done to simplify the code when pretty-printing the expansion
101101
result. Otherwise, this is an unnecessary transformation.
102102

103+
Due to some uncertainty regarding potentially-surprising fallout of AST rewrites, and some worries
104+
about exhaustiveness-checking (e.g. a tautological `if let` would be an error, which may be
105+
unexpected), this is put behind a feature gate named `if_let`.
106+
103107
## Examples
104108

105109
Source:

0 commit comments

Comments
 (0)