Description
Currently imports_granularity = 'One'
merges all imports into one "use" statement. In my opinion, functionally it does two separate things: 1) Combine all "use" statements; 2) apply imports_granularity = 'Crate'
inside the braces. Obviously it has the advantage of having no duplicate "use". However, I also really like the style of imports_granularity = 'Module'
. It's visually much clearer, and easier to modify one import without affecting other imports. Ideally, I'd love to see a style where it can combine the "one" use statement with the module style. For example,
use {
foo::b::{f, g},
foo::d::e,
foo::{a, b, c},
qux::{h, i},
};
I think imports_granularity
is orthogonal to this one "use" statement style, so why not introduce a separate option like one_use_statement
? With this new option, we will have 6 combinations in total:
-
imports_granularity = 'Crate'
+one_use_statement = false
-
imports_granularity = 'Module'
+one_use_statement = false
-
imports_granularity = 'Item'
+one_use_statement = false
These 3 will be exactly the same as current -
imports_granularity = 'Crate'
+one_use_statement = true
This is basically identical to the currentimports_granularity = 'One'
-
imports_granularity = 'Module'
+one_use_statement = true
The example is shown above -
imports_granularity = 'Item'
+one_use_statement = true
use {
foo::a,
foo::b,
foo::b::f,
foo::b::g,
foo::c,
foo::d::e,
qux::h,
qux::i,
};
With this new option, imports_granularity = 'One'
is no longer needed.