Merge pull request #3893 from rust-lang/push-zwrsqqxunozz

Ch. 18: further clarify about irrefutable patterns
This commit is contained in:
Chris Krycho 2024-04-18 14:00:38 -06:00 committed by GitHub
commit 8e5e4ae8df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -60,10 +60,10 @@ the code in the curly brackets, giving it a way to continue validly. Listing
<span class="caption">Listing 18-9: Using `if let` and a block with refutable <span class="caption">Listing 18-9: Using `if let` and a block with refutable
patterns instead of `let`</span> patterns instead of `let`</span>
Weve given the code an out! This code is perfectly valid, although it means we Weve given the code an out! This code is perfectly valid now. However,
cannot use an irrefutable pattern without receiving a warning. If we give `if if we give `if let` an irrefutable pattern (a pattern that will always
let` a pattern that will always match, such as `x`, as shown in Listing 18-10, match), such as `x`, as shown in Listing 18-10, the compiler will give a
the compiler will give a warning. warning.
```rust ```rust
{{#rustdoc_include ../listings/ch18-patterns-and-matching/listing-18-10/src/main.rs:here}} {{#rustdoc_include ../listings/ch18-patterns-and-matching/listing-18-10/src/main.rs:here}}