mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
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:
parent
0ee4195fb0
commit
a5ea38f75e
1 changed files with 12 additions and 0 deletions
|
@ -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)]
|
||||
|
|
Loading…
Reference in a new issue