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:
parent
532f3cb603
commit
ae8a4a8ef1
@ -227,10 +227,15 @@ impl DiagnosticsStore {
|
|||||||
.and_then(|diagnostic| diagnostic.measurement())
|
.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> {
|
pub fn iter(&self) -> impl Iterator<Item = &Diagnostic> {
|
||||||
self.diagnostics.values()
|
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.
|
/// Record new [`DiagnosticMeasurement`]'s.
|
||||||
|
Loading…
Reference in New Issue
Block a user