diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-07-24 15:18:48 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-24 15:18:48 +0530 |
| commit | 52c293c2bb3be96f3a8cc4043037e90e5ed4dda8 (patch) | |
| tree | 55141cdef2ce60b07578873cd760ec87ad91a263 /src | |
| parent | 89b9ddd0ddab2af0f6923244047c7c9fa216a048 (diff) | |
| parent | 1e0043eb6c445fb96981b6d46dae4c93af4fbda3 (diff) | |
| download | rust-52c293c2bb3be96f3a8cc4043037e90e5ed4dda8.tar.gz rust-52c293c2bb3be96f3a8cc4043037e90e5ed4dda8.zip | |
Rollup merge of #34989 - frewsxcv:fix-set-len-doc-example, r=nagisa
Fix incorrect 'memory leak' example for `Vec::set_len`. Example was written in https://github.com/rust-lang/rust/pull/34911 Issue was brought up in this comment: https://github.com/rust-lang/rust/commit/a005b2cd2ac679da7393e537aa05e2b7d32d36d5#commitcomment-18346958
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcollections/vec.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 2d77b38879b..967baccd274 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -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); /// } |
