Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow splitting multi-line use statements into separate single-line statements #4620

Open
Aaron1011 opened this issue Jan 2, 2021 · 1 comment

Comments

@Aaron1011
Copy link
Member

By default, rustfmt currently formats the following code

use std::{ReallyLongImportTypeNameOne, ReallyLongImportTypeNameTwo, ReallyLongImportTypeNameThree, ReallyLongImportTypeNameFour};

as

use std::{
    ReallyLongImportTypeNameFour, ReallyLongImportTypeNameOne, ReallyLongImportTypeNameThree,
    ReallyLongImportTypeNameTwo,
};

it would be nice to have an option to split these imports into multiple lines, with each line respecting the maximum line width:

use std::{ReallyLongImportTypeNameFour, ReallyLongImportTypeNameThree};
use std::{ReallyLongImportTypeNameOne, ReallyLongImportTypeNameTwo};
@calebcartwright
Copy link
Member

calebcartwright commented Jan 2, 2021

There's a ton of ongoing discussions about strategies/styles for imports, relevant issues linked below for reference. The gist though is that the default behavior isn't going to change, but there's going to be various config knobs for ordering, grouping, and granularity. I don't recall anyone asking for this particular style yet though should presumably be feasible for anyone sufficiently motivated

rust-lang/style-team#140
#3362, particularly #3362 (comment) and #3362 (comment)

(edit - fixed link)

@ytmimi ytmimi added a-imports `use` syntax p-low labels Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants