Skip to content

Commit 52c293c

Browse files
authored
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 #34911 Issue was brought up in this comment: a005b2c#commitcomment-18346958
2 parents 89b9ddd + 1e0043e commit 52c293c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/libcollections/vec.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,12 @@ impl<T> Vec<T> {
593593
/// ```
594594
///
595595
/// In this example, there is a memory leak since the memory locations
596-
/// owned by the vector were not freed prior to the `set_len` call:
596+
/// owned by the inner vectors were not freed prior to the `set_len` call:
597597
///
598598
/// ```
599-
/// let mut vec = vec!['r', 'u', 's', 't'];
600-
///
599+
/// let mut vec = vec![vec![1, 0, 0],
600+
/// vec![0, 1, 0],
601+
/// vec![0, 0, 1]];
601602
/// unsafe {
602603
/// vec.set_len(0);
603604
/// }

0 commit comments

Comments
 (0)