Skip to content

Commit

Permalink
Improve documentation for imports_merge_style
Browse files Browse the repository at this point in the history
  • Loading branch information
goffrie committed Jan 1, 2021
1 parent a95be15 commit a597c38
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1709,14 +1709,14 @@ pub enum Foo {}

Merge together related imports based on their paths.

This option requires `reorder_imports`, which is enabled by default.

- **Default value**: `Preserve`
- **Possible values**: `Preserve`, `Crate`, `Module`
- **Stable**: No (tracking issue: [#3362](/~https://github.com/rust-lang/rustfmt/issues/3362))
- **Stable**: No

#### `Preserve` (default):

Do not perform any merging and preserve the original structure written by the developer.

```rust
use foo::b;
use foo::b::{f, g};
Expand All @@ -1726,6 +1726,8 @@ use qux::{h, i};

#### `Crate`:

Merge imports from the same crate into a single `use` statement. Conversely, imports from different crates are split into separate statements.

```rust
use foo::{
a, b,
Expand All @@ -1738,6 +1740,8 @@ use qux::{h, i};

#### `Module`:

Merge imports from the same module into a single `use` statement. Conversely, imports from different modules are split into separate statements.

```rust
use foo::b::{f, g};
use foo::d::e;
Expand Down
3 changes: 3 additions & 0 deletions tests/source/imports_merge_style_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ use g::{self, b};
use h::{a};
use i::a::{self};
use j::{a::{self}};

use {k::{a, b}, l::{a, b}};
use {k::{c, d}, l::{c, d}};
3 changes: 3 additions & 0 deletions tests/target/imports_merge_style_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ use g::{self, a, b};
use h::a;
use i::a::{self};
use j::a::{self};

use k::{a, b, c, d};
use l::{a, b, c, d};

0 comments on commit a597c38

Please sign in to comment.