From 7b0fa6a4bdf8810b349af881de081c89123e775d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A1=BB=E8=AF=AD?= Date: Sat, 31 May 2025 17:27:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D19-10=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=8F=8A=E5=85=B6=E7=BC=96=E8=AF=91=E8=BF=94=E8=BF=98=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listing-19-10/output.txt | 12 ++++++------ .../listing-19-10/src/main.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 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 7f825dc..1c890d5 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 `let...else` pattern - --> src/main.rs:2:5 +warning: irrefutable `if let` pattern + --> src/main.rs:2:8 | -2 | let x = 5 else { - | ^^^^^^^^^ +2 | if let x = 5 { + | ^^^^^^^^^ | - = note: this pattern will always match, so the `else` clause is useless - = help: consider removing the `else` clause + = note: this pattern will always match, so the `if let` is useless + = help: consider replacing the `if let` with a `let` = note: `#[warn(irrefutable_let_patterns)]` on by default warning: `patterns` (bin "patterns") generated 1 warning diff --git a/listings/ch19-patterns-and-matching/listing-19-10/src/main.rs b/listings/ch19-patterns-and-matching/listing-19-10/src/main.rs index 5d1cc5c..2073948 100644 --- a/listings/ch19-patterns-and-matching/listing-19-10/src/main.rs +++ b/listings/ch19-patterns-and-matching/listing-19-10/src/main.rs @@ -1,7 +1,7 @@ fn main() { // ANCHOR: here - if let x = 5 else { - return; + if let x = 5 { + println!("{x}"); }; // ANCHOR_END: here }