pub fn stop(&mut self) -> Result<i64, Error> {
        match self.start_time {
            Some(start_time) => {
                let duration = time::now() - start_time;

                let elapsed = match self.time_scale {
                    Time::NSec => duration.num_nanoseconds().unwrap_or(0),
                    Time::USec => duration.num_microseconds().unwrap_or(0),
                    Time::MSec => duration.num_microseconds().unwrap_or(0),
                    Time::Sec => duration.num_seconds(),
                    Time::Min => duration.num_minutes(),
                    Time::Hour => duration.num_hours()
                };

                let val = *self.metric.val();
                self.metric.set_val(val + elapsed)?;

                // we need to record the time elapsed even if stop()
                // was called before a single unit of time_scale passed
                if elapsed != 0 {
                    self.start_time = None;
                }

                Ok(elapsed)
            },
            None => Err(Error::TimerNotStarted)
        }
    }
/// Stops the timer, updates the internal metric, and
/// returns the time elapsed since the last `start`. If
/// the timer was stopped too early or too late such that
/// the internal nanosecond, microsecond or millisecond value
/// over/under-flows, then elapsed time isn't updated.
Stops the timer, updates the internal metric, and
returns the time elapsed since the last `start`. If
the timer was stopped too early or too late such that
the internal nanosecond, microsecond or millisecond value
over/under-flows, then elapsed time isn't updated.
Stops the timer updates the internal metric and returns the time elapsed since the last ` start ` . If the timer was stopped too early or too late such that the internal nanosecond microsecond or millisecond value over / under - flows then elapsed time isn ' t updated .
pub fn stop(&mut self) -> Result<i64, Error> {
        match self.start_time {
            Some(start_time) => {
                let duration = time::now() - start_time;
                let elapsed = match self.time_scale {
                    Time::NSec => duration.num_nanoseconds().unwrap_or(0),
                    Time::USec => duration.num_microseconds().unwrap_or(0),
                    Time::MSec => duration.num_microseconds().unwrap_or(0),
                    Time::Sec => duration.num_seconds(),
                    Time::Min => duration.num_minutes(),
                    Time::Hour => duration.num_hours()
                };
                let val = *self.metric.val();
                self.metric.set_val(val + elapsed)?;
                // we need to record the time elapsed even if stop()
                // was called before a single unit of time_scale passed
                if elapsed != 0 {
                    self.start_time = None;
                }
                Ok(elapsed)
            },
            None => Err(Error::TimerNotStarted)
        }
    }
pub fn stop ( & mut self ) -> Result < i64 , Error > { match self . start_time { Some ( start_time ) => { let duration = time :: now ( ) - start_time ; let elapsed = match self . time_scale { Time :: NSec => duration . num_nanoseconds ( ) . unwrap_or ( 0 ) , Time :: USec => duration . num_microseconds ( ) . unwrap_or ( 0 ) , Time :: MSec => duration . num_microseconds ( ) . unwrap_or ( 0 ) , Time :: Sec => duration . num_seconds ( ) , Time :: Min => duration . num_minutes ( ) , Time :: Hour => duration . num_hours ( ) } ; let val = * self . metric . val ( ) ; self . metric . set_val ( val + elapsed ) ? ; // we need to record the time elapsed even if stop() // was called before a single unit of time_scale passed if elapsed != 0 { self . start_time = None ; } Ok ( elapsed ) } , None => Err ( Error :: TimerNotStarted ) } }
Stops the timer, updates the internal metric, and
returns the time elapsed since the last `start`.
Stops the timer updates the internal metric and returns the time elapsed since the last ` start ` .
&mut self