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:
a005b2cd2a (commitcomment-18346958)
This commit is contained in:
commit
52c293c2bb
@ -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);
|
||||
/// }
|
||||
|
Loading…
x
Reference in New Issue
Block a user