-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Rename first*
/last*
BTree{Set,Map}
methods to min*
/max*
#93709
Conversation
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
b353837
to
ea88efc
Compare
☔ The latest upstream changes (presumably #94350) made this pull request unmergeable. Please resolve the merge conflicts. |
Note: `BTreeSet::{first,last}` are renamed to `{get_min,get_max}` to avoid conflicts with `Ord::{min,max}`.
ea88efc
to
7876b5b
Compare
☔ The latest upstream changes (presumably #92962) made this pull request unmergeable. Please resolve the merge conflicts. |
We discussed this in the libs-api meeting last week. Having to use |
That's very unfortunate, though understandable. (and also surprising since generally inherit methods take over the trait ones (but turns out |
On the tracking issue there a lot of discussions on the names of these methods.
I propose that
min*
/max*
(reasoning below)TL;DR this PR renames first*/last* methods of
BTreeMap
andBTreeSet
as follows:In my opinion min/max terminology is a lot more self-documenting and less ambiguous. You can actually see that documentation is simplified a little, because there is no need to explain what "first" and "last" mean. The fact that first/last required explanation that they actually mean min/max suggests that min/max is a better naming.
You may also notice that std's usage of
BTreeSet
binded values returned from these methods to variables with_min
and_max
, which implies that this is what the code cares about and not firstness/lastness: