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

Doc Guarantee: BTree(Set|Map): IntoIter Iterate in Sorted by key Order #122817

Merged
merged 3 commits into from
Mar 22, 2024

Conversation

ultrabear
Copy link
Contributor

@ultrabear ultrabear commented Mar 21, 2024

This Doc-only PR adds text to the IntoIterator implementation and IntoIter type for both BTreeMap and BTreeSet that states that the returned items will be in sorted-by-key order, this is a guarantee that is made by the iter() and iter_mut() methods of BTreeMap/Set and BTreeMap respectively, but not on into_iter methods or types.

I don't know how the IntoIter iteration would not be sorted by key, and I would like to rely on that behavior for my prefix_array crate.

The text appended to IntoIter documentation is based on each types respective iter() method documentation, as is the text used in the IntoIterator documentation; they are slightly inconsistent between Set/Map, but they are consistent within their own types documentation.

@rustbot
Copy link
Collaborator

rustbot commented Mar 21, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Nilstrieb (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@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 Mar 21, 2024
Copy link
Member

@Noratrieb Noratrieb left a comment

Choose a reason for hiding this comment

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

this is already guaranteed for all other iterators and pretty obvious so I'll just approve it without asking libs-api.

there are top level docs

Iterators obtained from functions such as BTreeMap::iter, BTreeMap::values, or BTreeMap::keys produce their items in order by key, and take worst-case logarithmic and amortized constant time per item returned.

can you add into_iter there too?

library/alloc/src/collections/btree/set.rs Outdated Show resolved Hide resolved
library/alloc/src/collections/btree/map.rs Outdated Show resolved Hide resolved
@ultrabear
Copy link
Contributor Author

ultrabear commented Mar 21, 2024

can you add into_iter there too?

Added it to both Map and Set, with Set it previously only mentioned iter, I used "and" to include into_iter, which should be accurate because theres no keys/values etc methods in BTreeSet, so there shouldn't be confusion about only mentioning those two methods and using a closed joiner

@jhpratt
Copy link
Member

jhpratt commented Mar 21, 2024

@bors r=@Nilstrieb rollup

@bors
Copy link
Contributor

bors commented Mar 21, 2024

📌 Commit beb0c22 has been approved by Nilstrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 21, 2024
jhpratt added a commit to jhpratt/rust that referenced this pull request Mar 21, 2024
…lstrieb

Doc Guarantee: BTree(Set|Map):  `IntoIter` Iterate in Sorted by key Order

This Doc-only PR adds text to the IntoIterator implementation and IntoIter type for both BTreeMap and BTreeSet that states that the returned items will be in sorted-by-key order, this is a guarantee that is made by the iter() and iter_mut() methods of BTreeMap/Set and BTreeMap respectively, but not on into_iter methods or types.

I don't know how the IntoIter iteration would not be sorted by key, and I would like to rely on that behavior for my prefix_array crate.

The text appended to IntoIter documentation is based on each types respective iter() method documentation, as is the text used in the IntoIterator documentation; they are slightly inconsistent between Set/Map, but they are consistent within their own types documentation.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 21, 2024
…lstrieb

Doc Guarantee: BTree(Set|Map):  `IntoIter` Iterate in Sorted by key Order

This Doc-only PR adds text to the IntoIterator implementation and IntoIter type for both BTreeMap and BTreeSet that states that the returned items will be in sorted-by-key order, this is a guarantee that is made by the iter() and iter_mut() methods of BTreeMap/Set and BTreeMap respectively, but not on into_iter methods or types.

I don't know how the IntoIter iteration would not be sorted by key, and I would like to rely on that behavior for my prefix_array crate.

The text appended to IntoIter documentation is based on each types respective iter() method documentation, as is the text used in the IntoIterator documentation; they are slightly inconsistent between Set/Map, but they are consistent within their own types documentation.
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 21, 2024
Rollup of 6 pull requests

Successful merges:

 - rust-lang#121881 (std::net: adding acceptfilter feature for netbsd/freebsd.)
 - rust-lang#122817 (Doc Guarantee: BTree(Set|Map):  `IntoIter` Iterate in Sorted by key Order)
 - rust-lang#122829 (Implement `FusedIterator` for `gen` block)
 - rust-lang#122831 (make failure logs less verbose)
 - rust-lang#122837 (add test for rust-lang#122549)
 - rust-lang#122838 (Avoid noop rewrite of issues.txt)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 22, 2024
…iaskrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#121881 (std::net: adding acceptfilter feature for netbsd/freebsd.)
 - rust-lang#122817 (Doc Guarantee: BTree(Set|Map):  `IntoIter` Iterate in Sorted by key Order)
 - rust-lang#122826 (Add tests for shortcomings of associated type bounds)
 - rust-lang#122829 (Implement `FusedIterator` for `gen` block)
 - rust-lang#122831 (make failure logs less verbose)
 - rust-lang#122837 (add test for rust-lang#122549)
 - rust-lang#122838 (Avoid noop rewrite of issues.txt)
 - rust-lang#122841 (add 2 more tests for issues fixed by rust-lang#122749)
 - rust-lang#122843 (Add a never type option to make diverging blocks `()`)
 - rust-lang#122844 (add test for ice "cannot relate region: LUB(ReErased, ReError)")
 - rust-lang#122845 (Clippy subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fa99ebc into rust-lang:master Mar 22, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Mar 22, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 22, 2024
Rollup merge of rust-lang#122817 - ultrabear:ultrabear_btreedoc, r=Nilstrieb

Doc Guarantee: BTree(Set|Map):  `IntoIter` Iterate in Sorted by key Order

This Doc-only PR adds text to the IntoIterator implementation and IntoIter type for both BTreeMap and BTreeSet that states that the returned items will be in sorted-by-key order, this is a guarantee that is made by the iter() and iter_mut() methods of BTreeMap/Set and BTreeMap respectively, but not on into_iter methods or types.

I don't know how the IntoIter iteration would not be sorted by key, and I would like to rely on that behavior for my prefix_array crate.

The text appended to IntoIter documentation is based on each types respective iter() method documentation, as is the text used in the IntoIterator documentation; they are slightly inconsistent between Set/Map, but they are consistent within their own types documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants