Skip to content

Conversation

@xfbs
Copy link
Contributor

@xfbs xfbs commented May 4, 2023

This PR does some little refactoring of the resolve method.

  • I rearranged the code so that it reduces nesting. I do that by rearranging conditionals so that the error case returns early and then paves the way for the (non-indented) success path.
  • I give booleans a name (I tried, hope the names make sense) so that if statements "make more sense"
  • I turn an "expect" into an error and remove an unwrap() by using a match statement.

@xfbs xfbs changed the base branch from release to dev May 4, 2023 18:27
Copy link
Member

@Eh2406 Eh2406 left a comment

Choose a reason for hiding this comment

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

Thanks for the improvements!

@xfbs xfbs force-pushed the feature/cleanup branch from dcc6ea9 to 99883a3 Compare May 5, 2023 18:17
Copy link
Member

@mpizenberg mpizenberg left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! At first read I like most of it though I have a few remarks. We tend to be as specific as possible and favor reader over writer, so I'm not a super fan of unqualified import (for the log module).
Another nitpick, I'd prefer avoiding shadowing of variable (dependencies).

- Reduces nesting, to increase legibility of code
- Turns expect into error
- Removes unwrap()
@xfbs xfbs force-pushed the feature/cleanup branch from 99883a3 to a17445b Compare May 7, 2023 13:19
@xfbs
Copy link
Contributor Author

xfbs commented May 7, 2023

Thanks for the PR!

Happy to help, awesome crate :) We use this in production btw!

At first read I like most of it though I have a few remarks. We tend to be as specific as possible and favor reader over writer, so I'm not a super fan of unqualified import (for the log module).

I definitely agree with you! I tend to always explicitly include anything I use, with only two exceptions: log::* and tracing::* (never both, just either one of them ofc), just because these crates are so useful everywhere and it's nice to be able to just plop a debug!() somewhere. But this is a personal preference, so I changed to explicitly importing them (I hope that is what you prefer).

Another nitpick, I'd prefer avoiding shadowing of variable (dependencies).

That is one feature of Rust I love :D but I get you, so I changed it, I hope my naming makes sense (I'm not too familiar with the codebase).

Feel free to also just take some part of my PR and throw out other parts! Style is always very subjective, I don't want to enforce my ideas, just sharing something that might be useful.

Cheers!

@Eh2406
Copy link
Member

Eh2406 commented Jun 9, 2023

@mpizenberg are we good to merge now?

@mpizenberg
Copy link
Member

mpizenberg commented Jun 9, 2023 via email

@mpizenberg
Copy link
Member

Feels good to get rid of another unwrap and expect :)
Thanks again for the improvements.

@mpizenberg mpizenberg merged commit afe2d3c into pubgrub-rs:dev Jun 11, 2023
zanieb pushed a commit to astral-sh/pubgrub that referenced this pull request Nov 8, 2023
- Reduces nesting, to increase legibility of code
- Turns expect into error
- Removes unwrap()
This was referenced Nov 15, 2023
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