From 9226356b7b54c4c5b036b6fee00bba376245c5f3 Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 24 Jul 2026 22:32:21 +0200 Subject: feat(engine-ecs): add traversal query term --- engine-ecs/src/util.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'engine-ecs/src/util.rs') diff --git a/engine-ecs/src/util.rs b/engine-ecs/src/util.rs index f56a5c4..c52608a 100644 --- a/engine-ecs/src/util.rs +++ b/engine-ecs/src/util.rs @@ -34,6 +34,23 @@ impl VecExt for Vec } } +impl VecExt for ArrayVec +{ + fn insert_at_part_pt_by_key( + &mut self, + item: Item, + mut func: impl FnMut(&Item) -> &Key, + ) where + Key: Ord, + { + let key = func(&item); + + let insert_index = self.partition_point(|other_item| func(other_item) <= key); + + self.insert(insert_index, item); + } +} + pub trait StreamingIterator { type Item<'a> @@ -190,9 +207,16 @@ pub trait Array: + Sortable + sealed::Sealed { + fn map(self, func: impl FnMut(Item) -> T) -> impl Array; } -impl Array for [Item; CNT] {} +impl Array for [Item; CNT] +{ + fn map(self, func: impl FnMut(Item) -> T) -> impl Array + { + self.map(func) + } +} impl sealed::Sealed for [Item; CNT] {} @@ -414,6 +438,8 @@ macro_rules! const_assert { pub(crate) use const_assert; +use crate::util::array_vec::ArrayVec; + mod sealed { pub trait Sealed {} -- cgit v1.2.3-18-g5258