Skip to content
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

Fix clippy warnings #42

Merged
merged 2 commits into from Sep 27, 2021
Merged

Fix clippy warnings #42

merged 2 commits into from Sep 27, 2021

Conversation

Lireer
Copy link
Contributor

@Lireer Lireer commented Sep 26, 2021

While creating the other PRs I checked clippy and fixed the shown warnings. Some changes may have just been due to different styles, so feel free to change whatever you want or just close the PR.

If you don't mind I will probably try to reduce the number of clones/allocations being used.

// column width must be between the specified sizes
col_largest_width
.iter_mut()
.for_each(|width| *width = (*width).clamp(lower_column_width, upper_column_width));
Copy link
Owner

Choose a reason for hiding this comment

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

this is the first time I have seen clamp.

Copy link
Owner

@alexhallam alexhallam left a comment

Choose a reason for hiding this comment

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

I learned a lot from this.

@alexhallam
Copy link
Owner

Thanks. I was using rustfmt for linting. Could you let me know what the differences where between rustfmt and clippy?

@alexhallam alexhallam merged commit a56414a into alexhallam:main Sep 27, 2021
@Lireer
Copy link
Contributor Author

Lireer commented Sep 27, 2021

Thank you for being so fast with the reviews and merging. rustfmt just formats the code without checking the logic of the code, i.e. it even formats code the type checker would mark as incorrect. clippy is the official rust linter to check (some of) the logic in your code. It adds more lints than are already in the compiler. In my opinion it also teaches how to write better rust code and how to write "rustic" code, e.g. variable instead of return variable; as the final line of a function. I think it should already be installed if you installed rust using rustup.

@Lireer Lireer deleted the clippy branch September 27, 2021 00:23
@alexhallam
Copy link
Owner

Thanks for the explanations and thanks for the fantastic contributions.

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.

None yet

2 participants