Closed
Description
What it does
Changes trait imports that are not directly used to be anonymous.
Advantage
- Removes unused identifiers from scope.
- Clearly marks the intent of imports; seeing
use std::fmt::Write as _
is an indicator that Write is only being used so that its trait methods are in scope, and not referred to directly. - Lowers chance of conflicts with similarly named traits.
Drawbacks
No response
Example
fn foo() {
use std::fmt::Write;
let mut s = String::new();
s.write_char('x');
}
Could be written as:
fn foo() {
use std::fmt::Write as _; // anonymous
let mut s = String::new();
s.write_char('x');
}