Stopwatch elapsed secs f64 (#5978)
# Objective While coding in bevy I needed to get the elapsed time of a stopwatch as f64. I found it quite odd there are functions on Timer to get time as f64 but not on the Stopwatch. ## Solution - added a function that returns the `Stopwatch` elapsed time as `f64` --- ## Changelog ### Added - Added a function to get `Stopwatch` elapsed time as `f64` ### Fixed - The Stopwatch elapsed function had a wrong docs link
This commit is contained in:
parent
5d821fe1a7
commit
1378ab2859
@ -58,7 +58,8 @@ 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 {
|
||||
self.elapsed
|
||||
@ -79,11 +80,24 @@ 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.
|
||||
///
|
||||
/// # 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
|
||||
|
Loading…
Reference in New Issue
Block a user