From a5ea38f75e352d673d21bacd6ea94a02728b98a1 Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Sat, 11 Dec 2021 23:16:01 +0000 Subject: [PATCH] add methods to get reads and writes of Access (#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) --- crates/bevy_ecs/src/query/access.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/bevy_ecs/src/query/access.rs b/crates/bevy_ecs/src/query/access.rs index f735f36580..25c1f39054 100644 --- a/crates/bevy_ecs/src/query/access.rs +++ b/crates/bevy_ecs/src/query/access.rs @@ -115,6 +115,18 @@ impl Access { .map(SparseSetIndex::get_sparse_set_index) .collect() } + + /// Returns all read accesses. + pub fn reads(&self) -> impl Iterator + '_ { + self.reads_and_writes + .difference(&self.writes) + .map(T::get_sparse_set_index) + } + + /// Returns all write accesses. + pub fn writes(&self) -> impl Iterator + '_ { + self.writes.ones().map(T::get_sparse_set_index) + } } #[derive(Clone, Eq, PartialEq)]