Skip to content

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rami3l
Copy link
Member

@rami3l rami3l commented Jun 28, 2025

This PR has mainly converted the old code to use the new let-chains thanks to the clippy::collapsible_if lint. The overall readability seems to have been improved in a bunch of places.

@rami3l rami3l requested review from djc and ChrisDenton June 28, 2025 17:16
Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

}
}
let prefix = "content-length: ";
if let Ok(data) = str::from_utf8(header)
Copy link
Contributor

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.

Copy link
Member Author

@rami3l rami3l Jun 29, 2025

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...

@rami3l rami3l force-pushed the chore/clippy branch 2 times, most recently from b74a780 to 646a41b Compare June 29, 2025 02:54
@rami3l rami3l changed the title chore: fix new clippy warnings style: migrate the codebase to use let-chains Jun 29, 2025
@rami3l rami3l changed the title style: migrate the codebase to use let-chains style: migrate the codebase to let-chains Jun 29, 2025
@rami3l rami3l requested a review from djc June 29, 2025 03:04
Copy link
Member

@ChrisDenton ChrisDenton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants