Skip to content

Add notes about capacity effects to Vec::truncate() #39738

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

Merged
merged 1 commit into from
Feb 26, 2017

Conversation

keeperofdakeys
Copy link
Contributor

Add notes about the effects of Vec::truncate() and Vec::clear() on the capacity of a vector.

@rust-highfive
Copy link
Contributor

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@frewsxcv
Copy link
Member

Is this an implementation detail or something we want to guarantee?

@frewsxcv frewsxcv added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Feb 11, 2017
@@ -545,6 +545,9 @@ impl<T> Vec<T> {
/// The [`drain`] method can emulate `truncate`, but causes the excess
/// elements to be returned instead of dropped.
///
/// Note that his method has no effect on the allocated capacity
/// of the vector.
///
Copy link
Contributor

@brson brson Feb 13, 2017

Choose a reason for hiding this comment

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

Typo: "his"

@@ -1089,6 +1092,9 @@ impl<T> Vec<T> {

/// Clears the vector, removing all values.
///
/// Note that this method has no effect on the allocated capacity
/// of the vector, and is equivalent to calling `truncate(0)`.
Copy link
Member

Choose a reason for hiding this comment

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

Could this comment be a little less specific about the implementation? As it stands, the implementation is in the comment itself. (I am being a little paranoid here.)

@alexcrichton
Copy link
Member

Could you also update the similar methods on String with similar documentation?

@keeperofdakeys
Copy link
Contributor Author

@brson Are there any outstanding issues here?

@GuillaumeGomez
Copy link
Member

Sounds good to me. Thanks a lot for this add!

@bors: r+ rollup

@bors
Copy link
Collaborator

bors commented Feb 26, 2017

📌 Commit 4be5783 has been approved by GuillaumeGomez

@bors
Copy link
Collaborator

bors commented Feb 26, 2017

⌛ Testing commit 4be5783 with merge 60a0edc...

bors added a commit that referenced this pull request Feb 26, 2017
Add notes about capacity effects to Vec::truncate()

Add notes about the effects of Vec::truncate() and Vec::clear() on the capacity of a vector.
@bors
Copy link
Collaborator

bors commented Feb 26, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: GuillaumeGomez
Pushing 60a0edc to master...

@bors bors merged commit 4be5783 into rust-lang:master Feb 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants