mirror of
https://github.com/openharmony/third_party_rust_tinyvec.git
synced 2026-07-18 04:16:59 -04:00
Swap each element instead of calling rotate_left (#128)
This commit is contained in:
+3
-1
@@ -601,7 +601,9 @@ impl<A: Array> ArrayVec<A> {
|
||||
pub fn remove(&mut self, index: usize) -> A::Item {
|
||||
let targets: &mut [A::Item] = &mut self.deref_mut()[index..];
|
||||
let item = take(&mut targets[0]);
|
||||
targets.rotate_left(1);
|
||||
for i in 0..targets.len() - 1 {
|
||||
targets.swap(i, i + 1);
|
||||
}
|
||||
self.len -= 1;
|
||||
item
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user