@@ -10,7 +10,6 @@ use crate::{
10
10
Context , ContextHandle , RclReturnCode , RclrsError , ToResult , ENTITY_LIFECYCLE_MUTEX ,
11
11
} ;
12
12
use std:: {
13
- i64,
14
13
sync:: { atomic:: AtomicBool , Arc , Mutex , MutexGuard } ,
15
14
time:: Duration ,
16
15
} ;
@@ -173,12 +172,12 @@ impl Timer {
173
172
/// Returns true if the timer is due or past due to be called.
174
173
/// Returns false if the timer is not yet due or has been canceled.
175
174
pub fn is_ready ( & self ) -> bool {
176
- let mut timer = self . handle . lock ( ) ;
175
+ let timer = self . handle . lock ( ) ;
177
176
let mut is_ready = false ;
178
177
// SAFETY:
179
178
// * The timer is initialized, which is guaranteed by the constructor.
180
179
// * 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) } ;
182
181
183
182
// rcl_timer_is_ready should only error if incorrect arguments are given or something isn't initialised,
184
183
// both of which we control in this function.
@@ -190,13 +189,13 @@ impl Timer {
190
189
/// Get the time until the next call of the timer is due. Saturates to 0 if the timer is ready.
191
190
/// Returns [`RclReturnCode::TimerCanceled`] as an error if the timer has already been canceled.
192
191
pub fn time_until_next_call ( & self ) -> Result < Duration , RclrsError > {
193
- let mut timer = self . handle . lock ( ) ;
192
+ let timer = self . handle . lock ( ) ;
194
193
let mut remaining_time = 0 ;
195
194
// SAFETY:
196
195
// * The timer is initialized, which is guaranteed by the constructor.
197
196
// * The remaining_time pointer is allocated on the stack and is valid for the duration of this function.
198
197
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 ( ) ?;
200
199
}
201
200
Ok ( Duration :: from_nanos (
202
201
u64:: try_from ( remaining_time) . unwrap_or ( 0 ) ,
@@ -208,12 +207,12 @@ impl Timer {
208
207
/// previous call but instead the time since the current callback was called.
209
208
/// Saturates to 0 if the timer was last called in the future (i.e. the clock jumped).
210
209
pub fn time_since_last_call ( & self ) -> Duration {
211
- let mut timer = self . handle . lock ( ) ;
210
+ let timer = self . handle . lock ( ) ;
212
211
let mut elapsed_time = 0 ;
213
212
// SAFETY:
214
213
// * The timer is initialized, which is guaranteed by the constructor.
215
214
// * 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) } ;
217
216
218
217
// rcl_timer_get_time_since_last_call should only error if incorrect arguments are given
219
218
// or something isn't initialised, both of which we control in this function.
@@ -388,7 +387,7 @@ mod tests {
388
387
let new_period = Duration :: from_millis ( 100 ) ;
389
388
390
389
// 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) ;
392
391
393
392
// Calling get_period will trigger the debug_assert check on the rcl return value.
394
393
let retrieved_period = timer. get_period ( ) ;
0 commit comments