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

Improve the documentation of drain members #92902

Merged
merged 1 commit into from
Feb 19, 2022
Merged

Conversation

ssomers
Copy link
Contributor

@ssomers ssomers commented Jan 14, 2022

hopefully fixes #92765

@rust-highfive
Copy link
Collaborator

r? @yaahc

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 14, 2022
@rust-log-analyzer

This comment has been minimized.

library/alloc/src/string.rs Outdated Show resolved Hide resolved
Copy link
Member

@yaahc yaahc left a comment

Choose a reason for hiding this comment

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

The suggested changes look good to me. Happy to approve once you feel it's ready to merge.

@ssomers ssomers force-pushed the docter_drain branch 2 times, most recently from 291c1ec to f1b48b9 Compare February 8, 2022 10:40
@ssomers
Copy link
Contributor Author

ssomers commented Feb 8, 2022

Two more tweaks, in binary_heap.rs & set.rs

@ssomers
Copy link
Contributor Author

ssomers commented Feb 9, 2022

I noticed a commit in #92706 deprecating the use of "yielding" for iterators. Well, this commit happens to remove a few more.

@ssomers ssomers marked this pull request as ready for review February 11, 2022 00:35
@ssomers
Copy link
Contributor Author

ssomers commented Feb 11, 2022

I included "Leaking" paragraphs here, to keep this advanced topic separate from the main description. It possible to move them further away, to the description of the specific iterator type instead (e.g. from Vec::drain to Vec::Drain), but maybe that's too far away.

@ssomers ssomers marked this pull request as draft February 12, 2022 10:30
@ssomers ssomers marked this pull request as ready for review February 12, 2022 11:55
@bors
Copy link
Contributor

bors commented Feb 15, 2022

☔ The latest upstream changes (presumably #94024) made this pull request unmergeable. Please resolve the merge conflicts.

@ssomers ssomers force-pushed the docter_drain branch 2 times, most recently from ae5b7e2 to 4ec2211 Compare February 18, 2022 13:17
@yaahc
Copy link
Member

yaahc commented Feb 18, 2022

I like that idea. Because I think those running into situations caused by leak, are not going to cater for every possibility covered by their interpretation of the method's description. They're going to look up what happens now and cater for that.

I'm happy with the current version and ready to merge as is, but did you want to make any additional changes to use the # Current Implementation framing?

@yaahc
Copy link
Member

yaahc commented Feb 19, 2022

Dang github interface. I can't tell what changes you pushed since you force pushed. Can you describe the changes you made so I know where to look rather than having to re-read everything carefully again? Also, for further changes can you push them as independent commits and only rebase to recombine at the end before we merge1?

Footnotes

  1. or not at all

@ssomers
Copy link
Contributor Author

ssomers commented Feb 19, 2022

I like that idea. Because I think those running into situations caused by leak, are not going to cater for every possibility covered by their interpretation of the method's description. They're going to look up what happens now and cater for that.

I'm happy with the current version and ready to merge as is, but did you want to make any additional changes to use the # Current Implementation framing?

I forgot to propagate the change of "disappears" with "goes out of scope" in some places (as The Book calls it), fixed now.

It's fine for me now. As to the current implementation of leakage, I think for Vec::drain that is actually more complicated to describe than what the description now says (I thought it simply cleared the vector, but it leaves the part up to the start of the range), and hardly helps. It seems only useful for String::drain, but then I think why not leave out the possibilities of what else we might one day choose, which would be back to the initial wording in #93769, so I left it as is.

@ssomers
Copy link
Contributor Author

ssomers commented Feb 19, 2022

Dang github interface. I can't tell what changes you pushed since you force pushed.

I've often wondered how reviewers review, and I think I remember eventually applying a trick in an URL to see someone else's PR evolve or so, but I forgot how.

Can you describe the changes you made

I did, even before reading your request. Not saying that I deserve a cookie now, but at least I might be pardoned for changing this PR so often

push them as independent commits and only rebase to recombine at the end before we merge

Seems easier for everyone to me, but long ago I got the opposite message. I suppose because then the reviewer doesn't have to return after the recombine and there's no risk that the recombine isn't what it's supposed to be. It also allows using the github buttons to accept inline small changes.

@yaahc
Copy link
Member

yaahc commented Feb 19, 2022

Seems easier for everyone to me, but long ago I got the opposite message. I suppose because then the reviewer doesn't have to return after the recombine and there's no risk that the recombine isn't what it's supposed to be. It also allows using the github buttons to accept inline small changes.

Odd, the only time I've seen pushback is when I do a merge commit of master into a PR branch.

I did, even before reading your request. Not saying that I deserve a cookie now, but at least I might be pardoned for changing this PR so often

loool, another race condition1 it seems.

It's fine for me now. As to the current implementation of leakage, I think for Vec::drain that is actually more complicated to describe than what the description now says (I thought it simply cleared the vector, but it leaves the part up to the start of the range), and hardly helps. It seems only useful for String::drain, but then I think why not leave out the possibilities of what else we might one day choose, which would be back to the initial wording in #93769, so I left it as is.

sounds good! thank you ^_^

@bors r+

Footnotes

  1. fearless concurrency my ass

@bors
Copy link
Contributor

bors commented Feb 19, 2022

📌 Commit a677e60 has been approved by yaahc

@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 Feb 19, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 19, 2022
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#92902 (Improve the documentation of drain members)
 - rust-lang#93658 (Stabilize `#[cfg(panic = "...")]`)
 - rust-lang#93954 (rustdoc-json: buffer output)
 - rust-lang#93979 (Add debug assertions to validate NUL terminator in c strings)
 - rust-lang#93990 (pre rust-lang#89862 cleanup)
 - rust-lang#94006 (Use a `Field` in `ConstraintCategory::ClosureUpvar`)
 - rust-lang#94086 (Fix ScalarInt to char conversion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4fa71ed into rust-lang:master Feb 19, 2022
@rustbot rustbot added this to the 1.60.0 milestone Feb 19, 2022
@ssomers ssomers deleted the docter_drain branch February 20, 2022 10:53
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

drain() doc of vector (and others) is still unclear
6 participants