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

How to configure rustfmt to align types of struct fields? #1287

Closed
flosse opened this issue Jan 25, 2017 · 3 comments
Closed

How to configure rustfmt to align types of struct fields? #1287

flosse opened this issue Jan 25, 2017 · 3 comments

Comments

@flosse
Copy link

flosse commented Jan 25, 2017

Readability is quite important, so instead of

struct Foo {
    this_is_filed: f64,
    foo: String,
    another_field: u32,
    baz: bool,
    and_some_more: i8,
}

I'd like to use the much cleaner variant:

struct Foo {
    this_is_filed : f64,
    foo           : String,
    another_field : u32,
    baz           : bool,
    and_some_more : i8
}

How can I say to rustfmt that it should use the latter one?

@nrc
Copy link
Member

nrc commented Jan 25, 2017

It is not possible at the moment, sorry. It is somewhat tricky to implement and would need some deep changes to implement generally, but might be easier to do in restricted cases like this. If you're interested in implementing, I can mentor.

This is a dup of #1103, so closing.

@wasd96040501
Copy link

Is it now be possible? @nrc

@ytmimi
Copy link
Contributor

ytmimi commented Dec 2, 2022

@wasd96040501 please see the struct_field_align_threshold option.

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

4 participants