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.
This commit is contained in:
Sludge 2023-09-03 15:26:13 +02:00 committed by GitHub
parent 532f3cb603
commit ae8a4a8ef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -227,10 +227,15 @@ impl DiagnosticsStore {
.and_then(|diagnostic| diagnostic.measurement())
}
/// Return an iterator over all [`Diagnostic`].
/// Return an iterator over all [`Diagnostic`]s.
pub fn iter(&self) -> impl Iterator<Item = &Diagnostic> {
self.diagnostics.values()
}
/// Return an iterator over all [`Diagnostic`]s, by mutable reference.
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Diagnostic> {
self.diagnostics.values_mut()
}
}
/// Record new [`DiagnosticMeasurement`]'s.