📌  相关文章
📜  在同一行上覆盖打印生锈 - 无论代码示例

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

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

fn main() {
    let mut stdout = stdout();

    for i in 0..=100 {
        print!("\rProcessing {}%...", i);
        // or
        // stdout.write(format!("\rProcessing {}%...", i).as_bytes()).unwrap();

        stdout.flush().unwrap();
        sleep(Duration::from_millis(20));
    }
    println!();
}