Skip to content

Commit

Permalink
Fix incorrect 'memory leak' example for Vec::set_len.
Browse files Browse the repository at this point in the history
Example was written in rust-lang#34911

Issue was brought up in this comment:

rust-lang@a005b2c#commitcomment-18346958
  • Loading branch information
frewsxcv committed Jul 23, 2016
1 parent ad264f7 commit 1e0043e
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 1e0043e

Please sign in to comment.