summaryrefslogtreecommitdiff
path: root/ecs/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/util')
-rw-r--r--ecs/src/util/array_vec.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/ecs/src/util/array_vec.rs b/ecs/src/util/array_vec.rs
index 13a0349..5d0aac9 100644
--- a/ecs/src/util/array_vec.rs
+++ b/ecs/src/util/array_vec.rs
@@ -45,8 +45,8 @@ impl<Item, const CAPACITY: usize> ArrayVec<Item, CAPACITY>
unsafe {
std::ptr::copy(
- &self.items[index],
- &mut self.items[index + 1],
+ &raw const self.items[index],
+ &raw mut self.items[index + 1],
self.len - index,
);
}
@@ -115,3 +115,17 @@ impl<Item, const CAPACITY: usize> Default for ArrayVec<Item, CAPACITY>
}
}
}
+
+impl<Item, const CAPACITY: usize> Drop for ArrayVec<Item, CAPACITY>
+{
+ fn drop(&mut self)
+ {
+ for item in &mut self.items[..self.len] {
+ // SAFETY: The items from index 0 to the length index will always be
+ // initialized and satisfy all the invariants of the Item type.
+ unsafe {
+ item.assume_init_drop();
+ }
+ }
+ }
+}