ch19-01: fix outdated claim that if let conditions can't be combined (let chains) - #4803
Open
peterlodri-sec wants to merge 1 commit into
Open
ch19-01: fix outdated claim that if let conditions can't be combined (let chains)#4803peterlodri-sec wants to merge 1 commit into
if let conditions can't be combined (let chains)#4803peterlodri-sec wants to merge 1 commit into
Conversation
…9-01) let chains stabilized in Rust 1.88; the book targets edition 2024, where `if let Ok(age) = age && age > 30` is valid. Fixes rust-lang#4612.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4612.
Chapter 19-01 ("Conditional
if letExpressions") currently tells readers we can't writeif let Ok(age) = age && age > 30. But let chains stabilized in Rust 1.88, and this book targets the 2024 edition (edition = "2024", toolchain 1.97) — where that combination is valid: the binding introduced byif letis in scope for the conditions that follow it in the chain. I verified the outdated text is still present onmain, and the playground test in the issue confirms it compiles on stable.This is a minimal wording fix: it keeps the nested example (which still usefully demonstrates mixing
if let/else if/else if let) and replaces only the incorrect "we can't combine" sentence with an accurate note about let chains. Happy to adjust the framing if you'd prefer a different treatment. 🦀