Skip to content

Commit ae8a4a8

Browse files
authored
Add DiagnosticsStore::iter_mut (#9679)
# Objective Allow mutably iterating over all registered diagnostics. This is a useful utility method when exposing bevy's diagnostics in an editor that allows toggling whether the diagnostic is enabled. ## Solution - Add `iter_mut`, mirroring what `iter` does, just mutably. --- ## Changelog ### Added - Added `DiagnosticsStore::iter_mut` for mutably iterating over all registered diagnostics.
1 parent 532f3cb commit ae8a4a8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/bevy_diagnostic/src/diagnostic.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,15 @@ impl DiagnosticsStore {
227227
.and_then(|diagnostic| diagnostic.measurement())
228228
}
229229

230-
/// Return an iterator over all [`Diagnostic`].
230+
/// Return an iterator over all [`Diagnostic`]s.
231231
pub fn iter(&self) -> impl Iterator<Item = &Diagnostic> {
232232
self.diagnostics.values()
233233
}
234+
235+
/// Return an iterator over all [`Diagnostic`]s, by mutable reference.
236+
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Diagnostic> {
237+
self.diagnostics.values_mut()
238+
}
234239
}
235240

236241
/// Record new [`DiagnosticMeasurement`]'s.

0 commit comments

Comments
 (0)