From e91607e1d8599ba1104c79941128179af661397e Mon Sep 17 00:00:00 2001 From: EMachad0 Date: Tue, 13 Sep 2022 14:37:55 -0300 Subject: [PATCH 1/3] add elapsed_secs_f64 --- crates/bevy_time/src/stopwatch.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/bevy_time/src/stopwatch.rs b/crates/bevy_time/src/stopwatch.rs index cb9bd953f0e9f..043c167c41b2c 100644 --- a/crates/bevy_time/src/stopwatch.rs +++ b/crates/bevy_time/src/stopwatch.rs @@ -59,6 +59,7 @@ impl Stopwatch { /// # See Also /// /// [`elapsed_secs`](Stopwatch::elapsed) - if a `f32` value is desirable instead. + /// [`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if a `f64` is desirable instead. #[inline] pub fn elapsed(&self) -> Duration { self.elapsed @@ -79,11 +80,33 @@ impl Stopwatch { /// # See Also /// /// [`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead. + /// [`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if a `f64` is desirable instead. #[inline] pub fn elapsed_secs(&self) -> f32 { self.elapsed().as_secs_f32() } + /// Returns the elapsed time since the last [`reset`](Stopwatch::reset) + /// of the stopwatch, in seconds, as f64. + /// + /// # Examples + /// ``` + /// # use bevy_time::*; + /// use std::time::Duration; + /// let mut stopwatch = Stopwatch::new(); + /// stopwatch.tick(Duration::from_secs(1)); + /// assert_eq!(stopwatch.elapsed_secs_f64(), 1.0); + /// ``` + /// + /// # See Also + /// + /// [`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead. + /// [`elapsed_secs`](Stopwatch::elapsed_secs) - if a `f32` is desirable instead. + #[inline] + pub fn elapsed_secs_f64(&self) -> f64 { + self.elapsed().as_secs_f64() + } + /// Sets the elapsed time of the stopwatch. /// /// # Examples From 27330540baef0828757bf8956ac17642ad2e1154 Mon Sep 17 00:00:00 2001 From: EMachad0 Date: Tue, 13 Sep 2022 14:39:39 -0300 Subject: [PATCH 2/3] fix elapsed_secs wrong link --- crates/bevy_time/src/stopwatch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_time/src/stopwatch.rs b/crates/bevy_time/src/stopwatch.rs index 043c167c41b2c..38b3bbc0c783f 100644 --- a/crates/bevy_time/src/stopwatch.rs +++ b/crates/bevy_time/src/stopwatch.rs @@ -58,7 +58,7 @@ impl Stopwatch { /// /// # See Also /// - /// [`elapsed_secs`](Stopwatch::elapsed) - if a `f32` value is desirable instead. + /// [`elapsed_secs`](Stopwatch::elapsed_secs) - if a `f32` value is desirable instead. /// [`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if a `f64` is desirable instead. #[inline] pub fn elapsed(&self) -> Duration { From a488a02c9bb8b69edf73cf275328c3219821a306 Mon Sep 17 00:00:00 2001 From: EMachad0 Date: Tue, 13 Sep 2022 15:08:05 -0300 Subject: [PATCH 3/3] cut out example --- crates/bevy_time/src/stopwatch.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/crates/bevy_time/src/stopwatch.rs b/crates/bevy_time/src/stopwatch.rs index 38b3bbc0c783f..bb92bd25868c8 100644 --- a/crates/bevy_time/src/stopwatch.rs +++ b/crates/bevy_time/src/stopwatch.rs @@ -89,15 +89,6 @@ impl Stopwatch { /// Returns the elapsed time since the last [`reset`](Stopwatch::reset) /// of the stopwatch, in seconds, as f64. /// - /// # Examples - /// ``` - /// # use bevy_time::*; - /// use std::time::Duration; - /// let mut stopwatch = Stopwatch::new(); - /// stopwatch.tick(Duration::from_secs(1)); - /// assert_eq!(stopwatch.elapsed_secs_f64(), 1.0); - /// ``` - /// /// # See Also /// /// [`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead.