diff --git a/src/loop_logic.rs b/src/loop_logic.rs index f3b8a60f..6d7edc4d 100644 --- a/src/loop_logic.rs +++ b/src/loop_logic.rs @@ -1104,6 +1104,23 @@ mod tests { assert!(ret.is_err()); } + #[test] + fn remove_during_callback() { + use crate::sources::timer::{TimeoutAction, Timer}; + + let mut event_loop = EventLoop::::try_new().unwrap(); + let handle = event_loop.handle(); + let mut token = event_loop + .handle() + .insert_source(Timer::immediate(), move |_, _, token| { + handle.remove(*token); + TimeoutAction::Drop + }) + .unwrap(); + + event_loop.dispatch(Duration::ZERO, &mut token).unwrap(); + } + #[test] fn insert_source_no_interest() { use rustix::pipe::pipe;