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

Document collection From and FromIterator impls that drop duplicate keys. #134644

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

Conversation

kpreid
Copy link
Contributor

@kpreid kpreid commented Dec 22, 2024

This behavior is worth documenting because there are other plausible alternatives, such as panicking when a duplicate is encountered, and it reminds the programmer to consider whether they should, for example, coalesce duplicate keys first.

Followup to #89869.

…te keys.

This behavior is worth documenting because there are other plausible
alternatives, such as panicking when a duplicate is encountered, and
it reminds the programmer to consider whether they should, for example,
coalesce duplicate keys first.
@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2024

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 22, 2024
Copy link
Member

@the8472 the8472 left a comment

Choose a reason for hiding this comment

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

You're documenting the order here, this constrains future implementation changes.

And you're sometimes saying values and sometimes entries. That'd be even more constrianing because it means that either only values or keys and values must be replaced, depending on the method used, which can make a difference for keys that are equal but not identical.

@kpreid
Copy link
Contributor Author

kpreid commented Dec 22, 2024

Good point — I wasn't thinking of an appropriate middle ground between “no comment” and “document the precise behavior”. I have now updated the text so that in all cases it says

all but one (of the corresponding values)? will be dropped

which should be broad enough to permit all possible treatments of ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants