-
Notifications
You must be signed in to change notification settings - Fork 962
style: migrate the codebase to let-chains
#4397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
src/download/mod.rs
Outdated
} | ||
} | ||
let prefix = "content-length: "; | ||
if let Ok(data) = str::from_utf8(header) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cool and stuff but I feel like it would be more readable as a series of early returns with let-else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djc I think the new version is a bit error prone because it repeats the default return value true
so many times. What do you think?
PS: It's quite unfortunate that we can't use let-chains
with let-else
yet...
b74a780
to
646a41b
Compare
clippy
warningslet-chains
let-chains
let-chains
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
This PR has mainly converted the old code to use the new
let-chains
thanks to theclippy::collapsible_if
lint. The overall readability seems to have been improved in a bunch of places.