We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fee39ba commit 2a4c018Copy full SHA for 2a4c018
src/liballoc/vec.rs
@@ -813,14 +813,19 @@ impl<T> Vec<T> {
813
for i in 0..len {
814
if !f(&v[i]) {
815
del += 1;
816
+ unsafe {
817
+ ptr::read(&v[i]);
818
+ }
819
} else if del > 0 {
- v.swap(i - del, i);
820
+ let src: *const T = &v[i];
821
+ let dst: *mut T = &mut v[i - del];
822
823
+ ptr::copy_nonoverlapping(src, dst, 1);
824
825
}
826
827
- if del > 0 {
- self.truncate(len - del);
- }
828
+ self.len = len - del;
829
830
831
/// Removes all but the first of consecutive elements in the vector that resolve to the same
0 commit comments