Closed
Description
When importing things, my IDE isn't very smart about how it adds new use
statements. Thankfully rustfmt mostly cleans it up, but one thing it doesn't seem to do is move module imports into the same block as their children if some of their components are also imported.
A common case for me is when manually implementing Debug
on something - I often end up with the following after rustfmt cleans up (with imports_granularity = "Crate"
):
use std::{
fmt,
fmt::{Debug, Formatter},
};
...
impl Debug for MyStruct {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("MyStruct")
...
.finish()
}
}
It would be nice to have an option (or default behaviour, I'm not sure) to have rustfmt format the imports as:
use std::fmt::{self, Debug, Formatter};
...
It saves space, looks cleaner, and in a big import tree, makes it easier to read imo.
Metadata
Metadata
Assignees
Labels
No labels