Skip to content

Commit a5ea38f

Browse files
add methods to get reads and writes of Access<T> (#3166)
This makes it possible to e.g. show resource and component access on hover in [bevy_mod_debugdump](https://github.com/jakobhellermann/bevy_mod_debugdump/): ![grafik](https://user-images.githubusercontent.com/22177966/142773962-320f6e5b-608e-4abb-88b8-78da4fefc166.png)
1 parent 0ee4195 commit a5ea38f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

crates/bevy_ecs/src/query/access.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ impl<T: SparseSetIndex> Access<T> {
115115
.map(SparseSetIndex::get_sparse_set_index)
116116
.collect()
117117
}
118+
119+
/// Returns all read accesses.
120+
pub fn reads(&self) -> impl Iterator<Item = T> + '_ {
121+
self.reads_and_writes
122+
.difference(&self.writes)
123+
.map(T::get_sparse_set_index)
124+
}
125+
126+
/// Returns all write accesses.
127+
pub fn writes(&self) -> impl Iterator<Item = T> + '_ {
128+
self.writes.ones().map(T::get_sparse_set_index)
129+
}
118130
}
119131

120132
#[derive(Clone, Eq, PartialEq)]

0 commit comments

Comments
 (0)