Rustで時計作りました。。。


Rustで時計作りました...

use std::thread;
use std::time::Duration;

fn main() {
  let mut time: (i32, i32, i32) = (0,0,0);

  loop {
    time.2 = time.2 + 1;
    if time.2 == 60{
      time.2 = 0;
      time.1 = time.1 + 1;
    }
    if time.1 == 60{
      time.1 = 0;
      time.0 = time.0 + 1;
    }
    if time.0 == 24{
      time.0 = 0;
    }
    println!("{}時{}分{}秒",time.0,time.1,time.2);
    thread::sleep(Duration::from_millis(1000));
  }
}