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 documentation of Vec::split_off(...) #65739

Merged
merged 2 commits into from
Nov 17, 2019

Conversation

mqudsi
Copy link
Contributor

@mqudsi mqudsi commented Oct 23, 2019

The previous ordering of the sentences kept switching between the return
value and the value of self after execution, making it hard to follow.

Additionally, as rendered in the browser, the period in "Self. self"
was difficult to make out as being a sentence separator and not one code
block.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dtolnay (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 23, 2019
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Hmm, I find the original wording clearer here, although neither is great and I agree that the `Self`. `self` part comes out weird.

I think something like this would work best:

Returns a newly allocated vector containing elements [at, len) of self. The original vector will be left holding elements [0, at), with its capacity unchanged.

/// and the returned `Self` contains elements `[at, len)`.
///
/// Note that the capacity of `self` does not change.
/// Copies the range from `[at, len)` to a newly allocated `Self`
Copy link
Member

Choose a reason for hiding this comment

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

Note that these are moves not copies, as the Copy trait is not involved.

@dtolnay dtolnay added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 27, 2019
@JohnCSimon
Copy link
Member

Ping from triage.
@mqudsi , please address the comments from @dtolnay
Thank you!

@mqudsi
Copy link
Contributor Author

mqudsi commented Nov 6, 2019

What would be the best way to make it clear that this is not a "cheap" operation (my intention behind the (incorrect) usage of "copies" in the text)?

Since the original vector retains its previous capacity (which necessarily overlaps in memory with the range being split off), an allocation at least equivalent to [at, len) must be made.

@dtolnay
Copy link
Member

dtolnay commented Nov 10, 2019

I think "newly allocated vector" in my recommended wording is sufficient to indicate that there is a cost. I don't know that the cost is worth emphasizing beyond that.

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 16, 2019
@JohnCSimon
Copy link
Member

Ping from triage:
@dtolnay is this PR ready for review - can it be approved for merging?
cc: @mqudsi
Thanks

@dtolnay dtolnay added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 16, 2019
@dtolnay
Copy link
Member

dtolnay commented Nov 16, 2019

It looks like nothing has happened since my last review.

@mqudsi
Copy link
Contributor Author

mqudsi commented Nov 16, 2019

I'm sorry, I received the notifications about force pushes (presumably from rebasing) and thought that someone had taken over the issue.

I have pushed an update as requested.

The previous ordering of the sentences kept switching between the return
value and the value of `self` after execution, making it hard to follow.

Additionally, as rendered in the browser, the period in "`Self`. `self`"
was difficult to make out as being a sentence separator and not one code
block.
Remove the incorrect usage of "copy" as the trait is not called.
@dtolnay
Copy link
Member

dtolnay commented Nov 16, 2019

Sorry about the confusion -- @Dylan-DPC had pushed something to your branch, which I reverted. @Dylan-DPC please don't do that. It didn't even address the earlier review.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks! I am happy with the new wording.

@dtolnay
Copy link
Member

dtolnay commented Nov 16, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Nov 16, 2019

📌 Commit a36c3f6 has been approved by dtolnay

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 16, 2019
@mqudsi
Copy link
Contributor Author

mqudsi commented Nov 16, 2019

Thanks for reviewing and for helping with the wording!

fwiw, I personally didn't like all the self and Self in the original wording (rather than using the word "vector") but assumed that it was there for a reason or by convention. Glad it's not the case ☺

@ecstatic-morse
Copy link
Contributor

@bors rollup=always

Centril added a commit to Centril/rust that referenced this pull request Nov 17, 2019
Improve documentation of `Vec::split_off(...)`

The previous ordering of the sentences kept switching between the return
value and the value of `self` after execution, making it hard to follow.

Additionally, as rendered in the browser, the period in "`Self`. `self`"
was difficult to make out as being a sentence separator and not one code
block.
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Nov 17, 2019
Improve documentation of `Vec::split_off(...)`

The previous ordering of the sentences kept switching between the return
value and the value of `self` after execution, making it hard to follow.

Additionally, as rendered in the browser, the period in "`Self`. `self`"
was difficult to make out as being a sentence separator and not one code
block.
bors added a commit that referenced this pull request Nov 17, 2019
Rollup of 11 pull requests

Successful merges:

 - #65739 (Improve documentation of `Vec::split_off(...)`)
 - #66271 (syntax: Keep string literals in ABIs and `asm!` more precisely)
 - #66344 (rustc_plugin: Remove `Registry::register_attribute`)
 - #66381 (find_deprecation: deprecation attr may be ill-formed meta.)
 - #66395 (Centralize panic macro documentation)
 - #66456 (Move `DIAGNOSTICS` usage to `rustc_driver`)
 - #66465 (add missing 'static lifetime in docs)
 - #66466 (miri panic_unwind: fix hack for SEH platforms)
 - #66469 (Use "field is never read" instead of "field is never used")
 - #66471 (Add test for issue 63116)
 - #66477 (Clarify transmute_copy documentation example)

Failed merges:

r? @ghost
@bors bors merged commit a36c3f6 into rust-lang:master Nov 17, 2019
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.

6 participants