]> git.lizzy.rs Git - rust.git/commitdiff
Fix incorrect 'memory leak' example for `Vec::set_len`.
authorCorey Farwell <coreyf@rwell.org>
Sat, 23 Jul 2016 01:43:59 +0000 (21:43 -0400)
committerCorey Farwell <coreyf@rwell.org>
Sat, 23 Jul 2016 13:08:45 +0000 (09:08 -0400)
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

src/libcollections/vec.rs

index 2d77b38879b8eb8a959f4920b51abbf6bc66f57c..967baccd2740a7f724dbd17ca5a732aab33ac847 100644 (file)
@@ -593,11 +593,12 @@ pub fn as_mut_slice(&mut self) -> &mut [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);
     /// }