rustfmt
rustfmt copied to clipboard
Add option to put pub imports (aka exports) before normal imports
Context: When reorder_imports = true, rustfmt mixes pub imports in with private imports.
Please add an option to put pub imports (aka exports) before normal imports.
IMO it's not idiomatic to mix them in with normal imports because they are also exports and deserve extra attention so I usually put them before normal imports and then leave an empty line between.
Also, I would REALLY appreciate a configuration option to order imports as follows:
pubimports (exports) imports from std, core, alloc etc. (the built-in crates) imports from third-party crates imports from crates of the current workspace imports from the currentcrate
With an optional empty line between each group. Can you please add this :)
For someone who use group_imports = "StdExternalCrate" together with reorder_imports = true like me, my current workaround is
// define a macro somewhere
macro_rules! _____ {
() => {};
}
// use the macro between `use`s to avoid grouping by rustfmt
pub use a;
pub use b;
_____!();
pub(crate) use c;
pub(crate) use d;
_____!();
use e;
use f;