📜  rust 已用时间 - Rust 代码示例

📅  最后修改于: 2022-03-11 14:49:24.734000             🧑  作者: Mango

代码示例1
use std::time::{Duration, Instant};
use std::thread::sleep;

fn main() {
   let now = Instant::now();

   // we sleep for 2 seconds
   sleep(Duration::new(2, 0));
   // it prints '2'
   println!("{}", now.elapsed().as_secs());
}