Can anyone tell me what I'm doing wrong?
Yes; the compiler already does.
fn main() {
std::io::stdout().flush().expect("some error message");
}
error[E0599]: no method named `flush` found for type `std::io::Stdout` in the current scope
--> src/main.rs:3:23
|
3 | std::io::stdout().flush().expect("some error message");
| ^^^^^
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
candidate #1: `use std::io::Write;`
Emphasis on the help
and note
lines - use std::io::Write
.
All together:
use std::io::Write;
fn main() {
std::io::stdout().flush().expect("some error message");
}