How to count 5 minutes?

I need to count after 5 minutes in Rust. I thought I could use it time::now(), but it's out of date. What can I use and how to do it?

+3
source share
1 answer

If you click on the "obsolete" note in the documentation, you will see that it points to the repositoryrust-lang/time . In fact, it was ported from the standard library to its own package.

If you add the dependency on the box timeas indicated in the documentation, this works:

extern crate time;

use std::time::duration::Duration;

fn main() {
    let now = time::get_time();
    println!("now:   {}", now);
    let later = now + Duration::minutes(5);
    println!("later: {}", later);
}
+3
source

Source: https://habr.com/ru/post/1651299/


All Articles