Skip to content

Commit 052f442

Browse files
committed
Implement ClearableCollection for alll the other weird collections
1 parent e082720 commit 052f442

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

crates/bevy_ecs/src/system/scratch.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use alloc::{
2-
collections::{BinaryHeap, VecDeque},
2+
collections::{BTreeMap, BTreeSet, BinaryHeap, LinkedList, VecDeque},
33
vec::Vec,
44
};
55
use core::{
@@ -292,6 +292,42 @@ impl ClearableCollection for EntityHashSet {
292292
}
293293
}
294294

295+
impl<I> ClearableCollection for LinkedList<I> {
296+
fn capacity(&self) -> usize {
297+
0
298+
}
299+
300+
fn shrink_to(&mut self, _: usize) {}
301+
302+
fn clear(&mut self) {
303+
LinkedList::clear(self);
304+
}
305+
}
306+
307+
impl<K, V> ClearableCollection for BTreeMap<K, V> {
308+
fn capacity(&self) -> usize {
309+
0
310+
}
311+
312+
fn shrink_to(&mut self, _: usize) {}
313+
314+
fn clear(&mut self) {
315+
BTreeMap::clear(self);
316+
}
317+
}
318+
319+
impl<I> ClearableCollection for BTreeSet<I> {
320+
fn capacity(&self) -> usize {
321+
0
322+
}
323+
324+
fn shrink_to(&mut self, _: usize) {}
325+
326+
fn clear(&mut self) {
327+
BTreeSet::clear(self);
328+
}
329+
}
330+
295331
#[cfg(test)]
296332
mod tests {
297333
use alloc::vec::Vec;

0 commit comments

Comments
 (0)