I want to update otput. For example, i have a timer and every second program prints new second. But i need it dosn't create new line it should replace last line.
Code above:
let mut n = 0;
loop {
println!("Value: {}", n);
n += 1;
}
prints value of n
in new line:
Value: 0
Value: 1
Value: 2
Value: 3
Value: 4
Value: 5...
I need to update value in one line:
Value: 0
Value: 1
Value: 2
I have example:
use std::thread::sleep;
use std::time::Duration;
fn main() {
for i in 0..5 {
print!("{}", i);
sleep(Duration::from_millis(100000));
}
}
i need to print value of variable in one line. after run:
$ cargo run
It prints form 0 to 5 in one line
First iteration
$ cargo run
0
Second iteration
$ cargo run
1
Third iteration
$ cargo run
2