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

Rewrite/expand doc examples for Vec::set_len. #34911

Merged
merged 1 commit into from
Jul 21, 2016

Conversation

frewsxcv
Copy link
Member

No description provided.

@@ -532,9 +532,33 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// let mut v = vec![1, 2, 3, 4];
/// use std::ptr::drop_in_place;
Copy link
Member

Choose a reason for hiding this comment

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

idiom is to import the module, so just std::ptr...

@steveklabnik
Copy link
Member

I have a bunch of teeny nitpicks, but this is great! Thanks so much. r=me after they're fixed

@frewsxcv frewsxcv force-pushed the vec-set-len branch 2 times, most recently from 231227b to 102419a Compare July 19, 2016 03:10
@frewsxcv
Copy link
Member Author

Comments have been addressed. Thanks for the review!

@steveklabnik
Copy link
Member

@bors: r+ rollup

thanks so much!!!

@bors
Copy link
Contributor

bors commented Jul 19, 2016

📌 Commit 102419a has been approved by steveklabnik

@frewsxcv
Copy link
Member Author

failures:
---- vec::Vec<T>::set_len_0 stdout ----
    <anon>:10:5: 10:6 error: unresolved name `v` [E0425]
<anon>:10     v.set_len(3);
              ^
error: aborting due to previous error(s) 
thread 'vec::Vec<T>::set_len_0' panicked at 'Box<Any>', src/librustc/session/mod.rs:171
note: Run with `RUST_BACKTRACE=1` for a backtrace.
---- vec::Vec<T>::set_len_2 stdout ----
    <anon>:4:19: 4:27 error: unable to infer enough type information about `_`; type annotations or generic parameter binding required [E0282]
<anon>:4     let mut vec = Vec::new();
                           ^~~~~~~~
error: aborting due to previous error(s) 
thread 'vec::Vec<T>::set_len_2' panicked at 'Box<Any>', src/librustc/session/mod.rs:171
failures:
    vec::Vec<T>::set_len_0
    vec::Vec<T>::set_len_2

@frewsxcv
Copy link
Member Author

Changes made:

@@ -538,7 +554,7 @@ impl<T> Vec<T> {
     ///
     /// unsafe {
     ///     ptr::drop_in_place(&mut vec[3]);
-    ///     v.set_len(3);
+    ///     vec.set_len(3);
     /// }
     /// assert_eq!(vec, ['r', 'u', 's']);
     /// ```
@@ -559,7 +575,7 @@ impl<T> Vec<T> {
     /// values of unallocated memory:
     ///
     /// ```
-    /// let mut vec = Vec::new();
+    /// let mut vec: Vec<char> = Vec::new();
     ///
     /// unsafe {
     ///     vec.set_len(4);

r? @steveklabnik

@steveklabnik
Copy link
Member

ah, nice catch.

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Jul 19, 2016

📌 Commit a005b2c has been approved by steveklabnik

@bors
Copy link
Contributor

bors commented Jul 20, 2016

⌛ Testing commit a005b2c with merge afaaf4b...

@bors
Copy link
Contributor

bors commented Jul 20, 2016

💔 Test failed - auto-win-gnu-32-opt-rustbuild

@alexcrichton
Copy link
Member

@bors: retry

On Tue, Jul 19, 2016 at 10:01 PM, bors notifications@github.com wrote:

💔 Test failed - auto-win-gnu-32-opt-rustbuild
https://buildbot.rust-lang.org/builders/auto-win-gnu-32-opt-rustbuild/builds/1834


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#34911 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAD95DexKIaR5TmEMW3LFnrxVZpVNTSeks5qXauegaJpZM4JPUUu
.

@bors
Copy link
Contributor

bors commented Jul 21, 2016

⌛ Testing commit a005b2c with merge 3dcdb53...

@bors
Copy link
Contributor

bors commented Jul 21, 2016

💔 Test failed - auto-linux-64-cargotest

@alexcrichton
Copy link
Member

@bors: retry

On Wed, Jul 20, 2016 at 6:27 PM, bors notifications@github.com wrote:

💔 Test failed - auto-linux-64-cargotest
https://buildbot.rust-lang.org/builders/auto-linux-64-cargotest/builds/1202


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#34911 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAD95JWDGJcx0HSRDPWp1M54-OeXoUy1ks5qXsrygaJpZM4JPUUu
.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 21, 2016
Rewrite/expand doc examples for `Vec::set_len`.

None
bors added a commit that referenced this pull request Jul 21, 2016
Rollup of 7 pull requests

- Successful merges: #34854, #34855, #34880, #34895, #34911, #34921, #34930
- Failed merges: #33951, #34850
@bors bors merged commit a005b2c into rust-lang:master Jul 21, 2016
@frewsxcv frewsxcv deleted the vec-set-len branch July 23, 2016 01:45
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Jul 23, 2016
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 24, 2016
…=nagisa

Fix incorrect 'memory leak' example for `Vec::set_len`.

Example was written in rust-lang#34911

Issue was brought up in this comment:

rust-lang@a005b2c#commitcomment-18346958
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants