use std::{thread, time::Duration};
fn main() {
let on_timeout = || {
println!("timeout!");
};
let static_on_timeout = Box::leak(Box::new(on_timeout));
let cancel = spawn_timeout::spawn_timeout(static_on_timeout, Duration::from_secs(3));
let _ = spawn_timeout::spawn_timeout(static_on_timeout, Duration::from_secs(3));
thread::sleep(Duration::from_millis(1500));
cancel();
println!("The first instance of spawn_timeout has been succesfully stopped");
thread::sleep(Duration::from_millis(u64::MAX));
}