From 8022e8998290b067b8aa0cb9cba8ba410826bdab Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 21 May 2026 17:55:20 +0200 Subject: chore: rename ecs* crates to engine-ecs* --- ecs/src/util/array_vec.rs | 131 ---------------------------------------------- 1 file changed, 131 deletions(-) delete mode 100644 ecs/src/util/array_vec.rs (limited to 'ecs/src/util/array_vec.rs') diff --git a/ecs/src/util/array_vec.rs b/ecs/src/util/array_vec.rs deleted file mode 100644 index 5d0aac9..0000000 --- a/ecs/src/util/array_vec.rs +++ /dev/null @@ -1,131 +0,0 @@ -use std::mem::MaybeUninit; -use std::ops::{Deref, DerefMut}; - -#[derive(Debug)] -pub struct ArrayVec -{ - items: [MaybeUninit; CAPACITY], - len: usize, -} - -impl ArrayVec -{ - #[inline] - #[must_use] - pub fn len(&self) -> usize - { - self.len - } - - #[inline] - #[must_use] - pub fn is_empty(&self) -> bool - { - self.len == 0 - } - - pub fn push(&mut self, item: Item) - { - assert!(self.len < CAPACITY); - - self.items[self.len].write(item); - - self.len += 1; - } - - pub fn insert(&mut self, index: usize, item: Item) - { - assert!(index <= self.len); - assert!(self.len < CAPACITY); - - if index == self.len { - self.push(item); - return; - } - - unsafe { - std::ptr::copy( - &raw const self.items[index], - &raw mut self.items[index + 1], - self.len - index, - ); - } - - self.items[index].write(item); - - self.len += 1; - } -} - -impl Extend for ArrayVec -{ - fn extend>(&mut self, iter: IntoIter) - { - for item in iter { - self.push(item); - } - } -} - -impl AsRef<[Item]> for ArrayVec -{ - fn as_ref(&self) -> &[Item] - { - let ptr = &raw const self.items[..self.len]; - - unsafe { &*(ptr as *const [Item]) } - } -} - -impl AsMut<[Item]> for ArrayVec -{ - fn as_mut(&mut self) -> &mut [Item] - { - let ptr = &raw mut self.items[..self.len]; - - unsafe { &mut *(ptr as *mut [Item]) } - } -} - -impl Deref for ArrayVec -{ - type Target = [Item]; - - fn deref(&self) -> &Self::Target - { - self.as_ref() - } -} - -impl DerefMut for ArrayVec -{ - fn deref_mut(&mut self) -> &mut Self::Target - { - self.as_mut() - } -} - -impl Default for ArrayVec -{ - fn default() -> Self - { - Self { - items: [const { MaybeUninit::uninit() }; CAPACITY], - len: 0, - } - } -} - -impl Drop for ArrayVec -{ - 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(); - } - } - } -} -- cgit v1.2.3-18-g5258