Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

overwritting print on same line rust

use std::{
    io::{stdout, Write},
    thread::sleep,
    time::Duration,
};

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

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

        stdout.flush().unwrap();
        sleep(Duration::from_millis(20));
    }
    println!();
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #overwritting #print #line #rust
ADD COMMENT
Topic
Name
4+4 =