From a0b6207bc8bdfcc3c13f2d9fd8e17eb88e3722c5 Mon Sep 17 00:00:00 2001
From: Herbert Reiter <46045854+damoasda@users.noreply.github.com>
Date: Sat, 29 Mar 2025 21:03:38 +0100
Subject: [PATCH 1/2] Update text to `let...else`
---
src/ch19-02-refutability.md | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/ch19-02-refutability.md b/src/ch19-02-refutability.md
index 864d8e61dd..9771c235cf 100644
--- a/src/ch19-02-refutability.md
+++ b/src/ch19-02-refutability.md
@@ -50,9 +50,9 @@ pattern `Some(x)`, Rust rightfully produces a compiler error.
If we have a refutable pattern where an irrefutable pattern is needed, we can
fix it by changing the code that uses the pattern: instead of using `let`, we
-can use `if let`. Then if the pattern doesn’t match, the code will just skip
-the code in the curly brackets, giving it a way to continue validly. Listing
-19-9 shows how to fix the code in Listing 19-8.
+can use `let...else`. Then if the pattern doesn’t match, the code in the curly
+brackets will be executed, giving it a way to continue validly. Listing 19-9
+shows how to fix the code in Listing 19-8.
@@ -62,12 +62,11 @@ the code in the curly brackets, giving it a way to continue validly. Listing
-We’ve given the code an out! This code is perfectly valid now. However,
-if we give `if let` an irrefutable pattern (a pattern that will always
-match), such as `x`, as shown in Listing 19-10, the compiler will give a
-warning.
+We’ve given the code an out! This code is perfectly valid now. However, if we
+give `let...else` an irrefutable pattern (a pattern that will always match),
+such as `x`, as shown in Listing 19-10, the compiler will give a warning.
-
+
```rust
{{#rustdoc_include ../listings/ch19-patterns-and-matching/listing-19-10/src/main.rs:here}}
@@ -75,8 +74,8 @@ warning.
-Rust complains that it doesn’t make sense to use `if let` with an irrefutable
-pattern:
+Rust complains that it doesn’t make sense to use `let...else` with an
+irrefutable pattern:
```console
{{#include ../listings/ch19-patterns-and-matching/listing-19-10/output.txt}}
From b50329e487cf765b56fbcfdef2d36f1c65f12803 Mon Sep 17 00:00:00 2001
From: Herbert Reiter <46045854+damoasda@users.noreply.github.com>
Date: Sat, 29 Mar 2025 21:04:14 +0100
Subject: [PATCH 2/2] Update text to `let...else`
---
.../listing-19-10/output.txt | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/listings/ch19-patterns-and-matching/listing-19-10/output.txt b/listings/ch19-patterns-and-matching/listing-19-10/output.txt
index 97bc014ec1..2c484c135f 100644
--- a/listings/ch19-patterns-and-matching/listing-19-10/output.txt
+++ b/listings/ch19-patterns-and-matching/listing-19-10/output.txt
@@ -1,13 +1,13 @@
$ cargo run
Compiling patterns v0.1.0 (file:///projects/patterns)
-warning: irrefutable `if let` pattern
- --> src/main.rs:2:8
+warning: irrefutable `let...else` pattern
+ --> src/main.rs:2:5
|
-2 | if let x = 5 {
- | ^^^^^^^^^
+2 | let x = 5 else {
+ | ^^^^^^^^^
|
- = note: this pattern will always match, so the `if let` is useless
- = help: consider replacing the `if let` with a `let`
+ = note: this pattern will always match, so the `else` clause is useless
+ = help: consider removing the `else` clause
= note: `#[warn(irrefutable_let_patterns)]` on by default
warning: `patterns` (bin "patterns") generated 1 warning