diff options
author | HampusM <hampus@hampusmat.com> | 2025-05-24 17:24:46 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-05-24 17:24:46 +0200 |
commit | 4ad0f20f90147b663e0b151ffcdb88ca62c60281 (patch) | |
tree | b6a42629fe90a8f193bf5181f1105fe39cc99e90 /ecs | |
parent | c00396de8c566f88e203bf683763aed5699fc306 (diff) |
fix(ecs): add ArrayVec Drop impl
Diffstat (limited to 'ecs')
-rw-r--r-- | ecs/src/util/array_vec.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ecs/src/util/array_vec.rs b/ecs/src/util/array_vec.rs index 13a0349..a37b1f9 100644 --- a/ecs/src/util/array_vec.rs +++ b/ecs/src/util/array_vec.rs @@ -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(); + } + } + } +} |