@@ -10,7 +10,6 @@ use crate::{
1010 Context , ContextHandle , RclReturnCode , RclrsError , ToResult , ENTITY_LIFECYCLE_MUTEX ,
1111} ;
1212use std:: {
13- i64,
1413 sync:: { atomic:: AtomicBool , Arc , Mutex , MutexGuard } ,
1514 time:: Duration ,
1615} ;
@@ -173,12 +172,12 @@ impl Timer {
173172 /// Returns true if the timer is due or past due to be called.
174173 /// Returns false if the timer is not yet due or has been canceled.
175174 pub fn is_ready ( & self ) -> bool {
176- let mut timer = self . handle . lock ( ) ;
175+ let timer = self . handle . lock ( ) ;
177176 let mut is_ready = false ;
178177 // SAFETY:
179178 // * The timer is initialized, which is guaranteed by the constructor.
180179 // * The is_ready pointer is allocated on the stack and is valid for the duration of this function.
181- let ret = unsafe { rcl_timer_is_ready ( & mut * timer, & mut is_ready) } ;
180+ let ret = unsafe { rcl_timer_is_ready ( & * timer, & mut is_ready) } ;
182181
183182 // rcl_timer_is_ready should only error if incorrect arguments are given or something isn't initialised,
184183 // both of which we control in this function.
@@ -190,13 +189,13 @@ impl Timer {
190189 /// Get the time until the next call of the timer is due. Saturates to 0 if the timer is ready.
191190 /// Returns [`RclReturnCode::TimerCanceled`] as an error if the timer has already been canceled.
192191 pub fn time_until_next_call ( & self ) -> Result < Duration , RclrsError > {
193- let mut timer = self . handle . lock ( ) ;
192+ let timer = self . handle . lock ( ) ;
194193 let mut remaining_time = 0 ;
195194 // SAFETY:
196195 // * The timer is initialized, which is guaranteed by the constructor.
197196 // * The remaining_time pointer is allocated on the stack and is valid for the duration of this function.
198197 unsafe {
199- rcl_timer_get_time_until_next_call ( & mut * timer, & mut remaining_time) . ok ( ) ?;
198+ rcl_timer_get_time_until_next_call ( & * timer, & mut remaining_time) . ok ( ) ?;
200199 }
201200 Ok ( Duration :: from_nanos (
202201 u64:: try_from ( remaining_time) . unwrap_or ( 0 ) ,
@@ -208,12 +207,12 @@ impl Timer {
208207 /// previous call but instead the time since the current callback was called.
209208 /// Saturates to 0 if the timer was last called in the future (i.e. the clock jumped).
210209 pub fn time_since_last_call ( & self ) -> Duration {
211- let mut timer = self . handle . lock ( ) ;
210+ let timer = self . handle . lock ( ) ;
212211 let mut elapsed_time = 0 ;
213212 // SAFETY:
214213 // * The timer is initialized, which is guaranteed by the constructor.
215214 // * The elapsed_time pointer is allocated on the stack and is valid for the duration of this function.
216- let ret = unsafe { rcl_timer_get_time_since_last_call ( & mut * timer, & mut elapsed_time) } ;
215+ let ret = unsafe { rcl_timer_get_time_since_last_call ( & * timer, & mut elapsed_time) } ;
217216
218217 // rcl_timer_get_time_since_last_call should only error if incorrect arguments are given
219218 // or something isn't initialised, both of which we control in this function.
@@ -388,7 +387,7 @@ mod tests {
388387 let new_period = Duration :: from_millis ( 100 ) ;
389388
390389 // Calling set_period will trigger the debug_assert check on the rcl return value.
391- timer. set_period ( new_period. clone ( ) ) ;
390+ timer. set_period ( new_period) ;
392391
393392 // Calling get_period will trigger the debug_assert check on the rcl return value.
394393 let retrieved_period = timer. get_period ( ) ;
0 commit comments