Skip to content

Commit 59b3c83

Browse files
committed
Fix Vec::map_in_place not doing what is written in the comment
1 parent e1149f0 commit 59b3c83

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libcollections/vec.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,10 @@ impl<T> Vec<T> {
16611661
// Create a `Vec` from our `PartialVecZeroSized` and make sure the
16621662
// destructor of the latter will not run. None of this can panic.
16631663
let mut result = Vec::new();
1664-
unsafe { result.set_len(pv.num_u); }
1664+
unsafe {
1665+
result.set_len(pv.num_u);
1666+
mem::forget(pv);
1667+
}
16651668
result
16661669
}
16671670
}

0 commit comments

Comments
 (0)