mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user