Since 1.0.0 Beta i am very confused.
How i can flush() the standard output in the Terminal, for:
use std::thread;
use std::io::Write; // ?
fn main(){
let interval = 1000;
for x in 17u8..180{
thread::sleep_ms(interval);
print!("\r{} = {}", x, x as char);
// Write.flush();
}
}
std::io::Write is just the name of the trait that flush() is declared in. You need to actually call it on something that implements that trait. For stdout, you can call std::io::stdout() to get something that wraps standard out and implements the Write trait.
use std::thread;
use std::io::Write;
use std::io::stdout;
fn main(){
let interval = 1000;
for x in 17u8..180{
thread::sleep_ms(interval);
print!("\r{} = {}", x, x as char);
stdout().flush();
}
}