Does Rust have an equivalent of Python's threading.Timer?
Question: I'm looking for a timer which uses threads, not plain `time.sleep`:

    
    
    from threading import Timer
    
    def x():
        print "hello"
        t = Timer(2.0, x)
        t.start()
    
    t = Timer(2.0, x)
    t.start()
    


Answer: You can use the [timer](https://crates.io/crates/timer) crate

    
    
    extern crate timer;
    extern crate chrono;
    
    use timer::Timer;
    use chrono::Duration;
    use std::thread;
    
    fn x() {
        println!("hello");
    }
    
    fn main() {
        let timer = Timer::new();
        let guard = timer.schedule_repeating(Duration::seconds(2), x);
        // give some time so we can see hello printed
        // you can execute any code here
        thread::sleep(::std::time::Duration::new(10, 0));
        // stop repeating
        drop(guard);
    }
    

