Skip to content

Improve documentation of Vec::split_off(...) - #65739

Merged
bors merged 2 commits into
rust-lang:masterfrom
mqudsi:vec_split_off_docs
Nov 17, 2019
Merged

Improve documentation of Vec::split_off(...)#65739
bors merged 2 commits into
rust-lang:masterfrom
mqudsi:vec_split_off_docs

Conversation

@mqudsi

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 23, 2019

@dtolnaydtolnay left a comment

Copy link
Copy Markdown
Member

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.

Comment threadsrc/liballoc/vec.rs Outdated

Copy link
Copy Markdown
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.

@dtolnaydtolnay 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
Copy Markdown

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

@mqudsi

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
Member

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.

@JohnCSimonJohnCSimon 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
Copy Markdown

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

@dtolnaydtolnay 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
Copy Markdown
Member

It looks like nothing has happened since my last review.

@mqudsi

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
Member

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.

@dtolnaydtolnay left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

@bors r+

@bors

bors commented Nov 16, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit a36c3f6 has been approved by dtolnay

@borsbors 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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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.
@CentrilCentril mentioned this pull request Nov 17, 2019
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.
@JohnTitorJohnTitor mentioned this pull request Nov 17, 2019
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:masterNov 17, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: 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

@mqudsi@rust-highfive@JohnCSimon@dtolnay@bors@ecstatic-morse