Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Sep 20, 2022
1 parent 79fff80 commit d69ffae
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ The `else` block has to always diverge (evaluate to type `!`).
If an `else` block is present, restrictions apply on the expression:
It might not be a [_LazyBooleanExpression_], or end in a `}` token.

```rust
let (mut v, w) = (vec![1, 2, 3], 42); // The bindings may be mut or const
let Some(t) = v.pop() else { // Refutable patterns require an else block
panic!(); // The else block has to diverge
};
let [u, v] = [v[0], v[1]] else { // This pattern is irrefutable, so the compiler
// will lint as the else block is redundant.
panic!();
};
```

## Expression statements

> **<sup>Syntax</sup>**\
Expand Down

0 comments on commit d69ffae

Please sign in to comment.