You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
fnfoo(){use std::fmt::Write;letmut s = String::new();
s.write_char('x');}
Could be written as:
fnfoo(){use std::fmt::Writeas _;// anonymousletmut s = String::new();
s.write_char('x');}
The text was updated successfully, but these errors were encountered:
What it does
Changes trait imports that are not directly used to be anonymous.
Advantage
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.Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: