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

Relax more trait bounds #22

Merged
merged 2 commits into from
May 15, 2022

Conversation

clint-white
Copy link
Contributor

This PR removes the unnecessary bound N: Zero on the implementation of Counter::total(). As part of the refactoring done in ecebdf3, the .total() method was mistakenly moved to the wrong impl block.

It also relaxes the bound on the closure provided to Counter::most_common_tiebreaker() to FnMut, since that is all that is required by slice::sort_by().

This commit corrects ecebdf3 which moved `Counter::total()` to an
`impl` block with `N: Zero`, which is clearly not needed for this
method.
`slice::sort_by()` can take a closure that is `FnMut`; it does not
require `Fn`.  Thus, `Counter::most_common_tiebreaker()` could also
accept closures that are `FnMut`.

As an example, the test added by this commit will not compile with the
previous version of the code with the stricter `Fn` bound.
@coriolinus coriolinus merged commit e600fd0 into coriolinus:master May 15, 2022
@clint-white clint-white deleted the relax-more-trait-bounds branch May 15, 2022 18:54
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.

2 participants