Skip to content

Commit

Permalink
Rollup merge of rust-lang#34989 - frewsxcv:fix-set-len-doc-example, r…
Browse files Browse the repository at this point in the history
…=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
  • Loading branch information
Manishearth authored Jul 24, 2016
2 parents 89b9ddd + 1e0043e commit 52c293c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,12 @@ impl<T> Vec<T> {
/// ```
///
/// In this example, there is a memory leak since the memory locations
/// owned by the vector were not freed prior to the `set_len` call:
/// owned by the inner vectors were not freed prior to the `set_len` call:
///
/// ```
/// let mut vec = vec!['r', 'u', 's', 't'];
///
/// let mut vec = vec![vec![1, 0, 0],
/// vec![0, 1, 0],
/// vec![0, 0, 1]];
/// unsafe {
/// vec.set_len(0);
/// }
Expand Down

0 comments on commit 52c293c

Please sign in to comment.