Skip to content

Commit c60764b

Browse files
committed
Add example
1 parent b30ee54 commit c60764b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/statements.md

+11
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ The `else` block must always diverge (evaluate to the [never type]).
7474
If an `else` block is present, restrictions apply on the expression:
7575
It must not be a [_LazyBooleanExpression_], or end in a `}` token.
7676

77+
```rust
78+
let (mut v, w) = (vec![1, 2, 3], 42); // The bindings may be mut or const
79+
let Some(t) = v.pop() else { // Refutable patterns require an else block
80+
panic!(); // The else block must diverge
81+
};
82+
let [u, v] = [v[0], v[1]] else { // This pattern is irrefutable, so the compiler
83+
// will lint as the else block is redundant.
84+
panic!();
85+
};
86+
```
87+
7788
## Expression statements
7889

7990
> **<sup>Syntax</sup>**\

0 commit comments

Comments
 (0)