From 8a3fd3b1c52596eda2705eeb2ec99ae9882b822e Mon Sep 17 00:00:00 2001 From: Fred Morcos Date: Thu, 17 May 2018 14:01:00 +0200 Subject: [PATCH] Add a #[must_use] directive to add_timer() If the result of add_timer is unused, the timer will be dropped immediately and the callback won't fire. A small gotcha but can save some debugging time. --- src/sdl2/timer.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdl2/timer.rs b/src/sdl2/timer.rs index af6f0ebc..181d5843 100644 --- a/src/sdl2/timer.rs +++ b/src/sdl2/timer.rs @@ -13,6 +13,7 @@ impl TimerSubsystem { /// /// * when the timer is dropped /// * or when the callback returns a non-positive continuation interval + #[must_use = "if unused the Timer will be dropped immediately"] pub fn add_timer<'b, 'c>(&'b self, delay: u32, callback: TimerCallback<'c>) -> Timer<'b, 'c> { unsafe { let callback = Box::new(callback);