Calling flush() without calling "use std::io::Write;"

I want to call commands like flush() without calling use std::io::Write;. Like I can use stdin() as std::io::stdin() without calling use std::io::stdin;

You could put it in one file e.g. "reexport.rs"

pub use std::io::Write;
// etc

then in your files

use crate::reexports::*;

Wouldn't recommend it though, it's not very clear.
Use an IDE like clion that can add imports automatically.

You can do

std::io::Write::flush(&mut your_io_resource);

without importing the trait.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.