mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 15:14:50 +00:00
Add EntityMap::iter()
(#6935)
# Objective There is currently no way to iterate over key/value pairs inside an `EntityMap`, which makes the usage of this struct very awkward. I couldn't think of a good reason why the `iter()` function should not be exposed, considering the interface already exposes `keys()` and `values()`, so I made this PR. ## Solution Implement `iter()` for `EntityMap` in terms of its inner map type.
This commit is contained in:
parent
00fa0d8cf2
commit
f8e4b755ff
1 changed files with 5 additions and 0 deletions
|
@ -117,4 +117,9 @@ impl EntityMap {
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.map.is_empty()
|
self.map.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An iterator visiting all (key, value) pairs in arbitrary order.
|
||||||
|
pub fn iter(&self) -> impl Iterator<Item = (Entity, Entity)> + '_ {
|
||||||
|
self.map.iter().map(|(from, to)| (*from, *to))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue