September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
27
Task/Draw-a-clock/Rust/draw-a-clock.rust
Normal file
27
Task/Draw-a-clock/Rust/draw-a-clock.rust
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// cargo-deps: time="0.1"
|
||||
extern crate time;
|
||||
use std::thread;
|
||||
|
||||
static TOP: &'static str = " ⡎⢉⢵ ⠀⢺⠀ ⠊⠉⡱ ⠊⣉⡱ ⢀⠔⡇ ⣏⣉⡉ ⣎⣉⡁ ⠊⢉⠝ ⢎⣉⡱ ⡎⠉⢱ ⠀⠶⠀";
|
||||
static BOT: &'static str = " ⢗⣁⡸ ⢀⣸⣀ ⣔⣉⣀ ⢄⣀⡸ ⠉⠉⡏ ⢄⣀⡸ ⢇⣀⡸ ⢰⠁⠀ ⢇⣀⡸ ⢈⣉⡹ ⠀⠶⠀";
|
||||
|
||||
fn main() {
|
||||
let top: Vec<&str> = TOP.split_whitespace().collect();
|
||||
let bot: Vec<&str> = BOT.split_whitespace().collect();
|
||||
|
||||
loop {
|
||||
let tm = &time::now().rfc822().to_string()[17..25];
|
||||
let top_str: String = tm.chars().map(|x| top[x as usize - '0' as usize]).collect();
|
||||
let bot_str: String = tm.chars().map(|x| bot[x as usize - '0' as usize]).collect();
|
||||
|
||||
clear_screen();
|
||||
println!("{}", top_str);
|
||||
println!("{}", bot_str);
|
||||
|
||||
thread::sleep(std::time::Duration::from_secs(1));
|
||||
}
|
||||
}
|
||||
|
||||
fn clear_screen() {
|
||||
println!("{}[H{}[J", 27 as char, 27 as char);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue