From 8b30dc635450363661397e7f63d054e6efbce547 Mon Sep 17 00:00:00 2001 From: MiniaczQ Date: Sat, 13 Nov 2021 04:26:42 +0000 Subject: [PATCH] `iter_mut()` for Assets type (#3118) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective Fixes #3117 ## Solution I took `get_mut()` and did it for all the elements 😏 Co-authored-by: MiniaczQ --- crates/bevy_asset/src/assets.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index d444cdee2d..d92e535f80 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -133,6 +133,15 @@ impl Assets { self.assets.iter().map(|(k, v)| (*k, v)) } + pub fn iter_mut(&mut self) -> impl Iterator { + for id in self.assets.keys() { + self.events.send(AssetEvent::Modified { + handle: Handle::weak(*id), + }); + } + self.assets.iter_mut().map(|(k, v)| (*k, v)) + } + pub fn ids(&self) -> impl Iterator + '_ { self.assets.keys().cloned() }