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.
This commit is contained in:
Fred Morcos
2018-05-18 00:08:07 +02:00
committed by Cobrand
parent e9f2e33797
commit 8a3fd3b1c5
+1
View File
@@ -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);