Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Sep 24, 2022
1 parent 9df3a29 commit 3eacf00
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 @@ -75,6 +75,17 @@ If the pattern does not match (this requires it to be refutable), the `else`
block is executed.
The `else` block must always diverge (evaluate to the [never type]).

```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 must 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 3eacf00

Please sign in to comment.