Skip to content

Commit b8ee91e

Browse files
committed
Implement ClearableCollection for alll the other weird collections
1 parent f54c2ee commit b8ee91e

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::{
@@ -294,6 +294,42 @@ impl ClearableCollection for EntityHashSet {
294294
}
295295
}
296296

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

0 commit comments

Comments
 (0)