Timer::set_interval

Don't return an Option, just return 0 when the timer is not started.
As discussed in the API review, the rational is that the interval is
just like a field in a struct and when the struct is default
constructed, it is initialized to 0
This commit is contained in:
Olivier Goffart 2024-09-17 18:01:10 +02:00
parent bcdc3e1cee
commit d2bd5366f4
5 changed files with 13 additions and 20 deletions

View file

@ -1068,8 +1068,7 @@ fn generate_sub_component(
quote!(
if #running {
let interval = core::time::Duration::from_millis(#interval as u64);
let old_interval = self.#ident.interval();
if old_interval != Some(interval) || !self.#ident.running() {
if !self.#ident.running() || interval != self.#ident.interval() {
let self_weak = self.self_weak.get().unwrap().clone();
self.#ident.start(sp::TimerMode::Repeated, interval, move || {
if let Some(self_rc) = self_weak.upgrade() {