From 18c08dd86022397a371326ed84499ed44998aefa Mon Sep 17 00:00:00 2001 From: Patrick Greene Date: Mon, 6 Sep 2021 19:16:08 +0000 Subject: [PATCH] add get_history function to Diagnostic (#2772) # Objective - Allow access to diagnostic history value. - Fixes #2771. ## Solution - Add Diagnostic::get_history function. --- crates/bevy_diagnostic/src/diagnostic.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/bevy_diagnostic/src/diagnostic.rs b/crates/bevy_diagnostic/src/diagnostic.rs index 4256d72e98..7d8cfaebca 100644 --- a/crates/bevy_diagnostic/src/diagnostic.rs +++ b/crates/bevy_diagnostic/src/diagnostic.rs @@ -119,6 +119,14 @@ impl Diagnostic { pub fn get_max_history_length(&self) -> usize { self.max_history_length } + + pub fn values(&self) -> impl Iterator { + self.history.iter().map(|x| &x.value) + } + + pub fn measurements(&self) -> impl Iterator { + self.history.iter() + } } /// A collection of [Diagnostic]s