summaryrefslogtreecommitdiff
path: root/engine/src/util.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-07-03 04:41:21 +0200
committerHampusM <hampus@hampusmat.com>2026-07-03 04:41:21 +0200
commitdc0a41019736b3fbd92e302252c33f7ffb65467d (patch)
tree906f71a534ac59f9e6c42c48f89eb2fff99c4464 /engine/src/util.rs
parente9200b7e4b107aea9045b2e013f0a9ca5e355456 (diff)
feat(engine): add monitor retrieval fns to windowing::Context
Diffstat (limited to 'engine/src/util.rs')
-rw-r--r--engine/src/util.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/engine/src/util.rs b/engine/src/util.rs
index 454a776..819b2da 100644
--- a/engine/src/util.rs
+++ b/engine/src/util.rs
@@ -6,7 +6,7 @@ use portable_atomic::AtomicU128;
use crate::ecs::util::VecExt;
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct MapVec<Key: Ord, Value>
{
inner: Vec<(Key, Value)>,
@@ -66,6 +66,20 @@ impl<Key: Ord, Value> MapVec<Key, Value>
}
}
+impl<Key: Ord, Value> FromIterator<(Key, Value)> for MapVec<Key, Value>
+{
+ fn from_iter<Iter: IntoIterator<Item = (Key, Value)>>(iter: Iter) -> Self
+ {
+ let mut items = iter.into_iter().collect::<Vec<_>>();
+
+ if !items.is_sorted_by_key(|(key, _)| key) {
+ items.sort_by(|(key_a, _), (key_b, _)| key_a.cmp(key_b));
+ }
+
+ Self { inner: items }
+ }
+}
+
impl<Key: Ord, Value> Default for MapVec<Key, Value>
{
fn default() -> Self