Closed
Description
What it does
When importing names that are not used directly, but used as a trait, I think it is better to use the as _
clause to avoid polluting current scope with unused names.
Advantage
- does not introduce unused names into the current scope
- fewer potential "got-chas"
Drawbacks
No response
Example
// the `Write` here is never actually used
use std::fmt::Write;
fn main() {
let mut s = String::new();
let _ = write!(s, "hello, world!");
println!("{s}");
}
Could be written as:
use std::fmt::Write as _;
...