Skip to content

refactor: group imports #251

Merged
Mossaka merged 3 commits into
containerd:mainfrom
Mossaka:group-imports
Aug 20, 2023
Merged

refactor: group imports #251
Mossaka merged 3 commits into
containerd:mainfrom
Mossaka:group-imports

Conversation

@Mossaka

@Mossaka Mossaka commented Aug 18, 2023

Copy link
Copy Markdown
Member

This commits adds a rustfmt configuration to create three import groups:

  1. std, core
  2. external
  3. local crates

and group all the imports based on these three groups.

Changed cargo fmt --all to cargo +nightly fmt --all as this feature isn't stable

This commits adds a rustfmt configuration to create three import groups:
1. std, core
2. external
3. local crates

and group all the imports based on these three groups.

Changed `cargo fmt --all` to `cargo +nightly fmt --all` as this feature
isn't stable

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>

@jprendes jprendes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this change! I didn't know you could configure rustfmt like this.
Thanks @Mossaka !

devigned
devigned previously approved these changes Aug 18, 2023

@devigned devigned left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much cleaner!

@Mossaka

Mossaka commented Aug 18, 2023

Copy link
Copy Markdown
Member Author

Question: do you all prefer imports granularity to be "crate" or "module", or something else?

See https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#imports_granularity

This commits adds a imports_granularity configuration to
rustfmt.toml to merge imports from the same module into a single
use statement.

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
@jprendes

jprendes commented Aug 18, 2023

Copy link
Copy Markdown
Collaborator

Question: do you all prefer imports granularity to be "crate" or "module", or something else?

Module is fine for me. Either is fine actually. To me consistency is more important than what particular option we choose.

@Mossaka

Mossaka commented Aug 18, 2023

Copy link
Copy Markdown
Member Author

I am going to merge this in. @jsturtevant any concerns on merging? For rebasing, I think the easier way is to copy the rustfmt.toml file and then ran cargo +nightly fmt --all before rebasing this PR.

@jsturtevant

Copy link
Copy Markdown
Contributor

we will see how rebasing #238 will go, might make me 😢

To me consistency is more important than what particular option we choose.

💯

@Mossaka

Mossaka commented Aug 20, 2023

Copy link
Copy Markdown
Member Author

Merging it

@Mossaka Mossaka merged commit 52e55cf into containerd:main Aug 20, 2023
@Mossaka Mossaka deleted the group-imports branch August 20, 2023 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants