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)
This commit is contained in:
Jakob Hellermann 2021-12-11 23:16:01 +00:00
parent 0ee4195fb0
commit a5ea38f75e

View file

@ -115,6 +115,18 @@ impl<T: SparseSetIndex> Access<T> {
.map(SparseSetIndex::get_sparse_set_index)
.collect()
}
/// Returns all read accesses.
pub fn reads(&self) -> impl Iterator<Item = T> + '_ {
self.reads_and_writes
.difference(&self.writes)
.map(T::get_sparse_set_index)
}
/// Returns all write accesses.
pub fn writes(&self) -> impl Iterator<Item = T> + '_ {
self.writes.ones().map(T::get_sparse_set_index)
}
}
#[derive(Clone, Eq, PartialEq)]