You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Libraries using nested enums with struct members lead to deep pattern matching to extract the desired data. When starting a nested destructure, placing a newline before the type of the item and the first field does not add any additional visual cues about what is being destructured but does add unnecessary whitespace that makes it harder to differentiate the nested destructure in the match arm from match bodies and match/body pairs.
indent_style = "Visual" and several other options appear not to convince rustfmt to put these names and types on the same line, resulting in match patterns visually larger than the data being matched.
With several compact and visual indent options on we still get so many lines
match ev {Event::WindowEvent{event:// why WindowEvent::KeyboardInput{input:// so manyKeyboardInput{modifiers:// newlines?ModifiersState{shift:false,ctrl:false,alt:false,logo:false,
..
},
..
},
..
},
..
} => true,// additional match arms}
Without newlines between nested destructure name & type
match ev {// How it should beEvent::WindowEvent{event:WindowEvent::KeyboardInput{input:KeyboardInput{modifiers:ModifiersState{shift:false,ctrl:false,alt:false,logo:false,
..
},
..
},
..
},
..
} => true,// additional match arms}
We still can pile up quite a bit of vertical space with the field omissions and closing braces, but moving any braces seems to require breaking up each member's fields into two indent levels (if .. is considered a field) and the match arm shouldn't be moved under any circumstance, so there's a unique solution, which we're already at in this example.
rustfmt.toml used to obtain the odious long version
Libraries using nested enums with struct members lead to deep pattern matching to extract the desired data. When starting a nested destructure, placing a newline before the type of the item and the first field does not add any additional visual cues about what is being destructured but does add unnecessary whitespace that makes it harder to differentiate the nested destructure in the match arm from match bodies and match/body pairs.
indent_style = "Visual"
and several other options appear not to convince rustfmt to put these names and types on the same line, resulting in match patterns visually larger than the data being matched.Data being destructured
With several compact and visual indent options on we still get so many lines
Without newlines between nested destructure name & type
We still can pile up quite a bit of vertical space with the field omissions and closing braces, but moving any braces seems to require breaking up each member's fields into two indent levels (if
..
is considered a field) and the match arm shouldn't be moved under any circumstance, so there's a unique solution, which we're already at in this example.rustfmt.toml used to obtain the odious long version
What I recommend is a similar option
overflow_delimited_expr = true
but applied to nested destructuring, not just function argument lists.The text was updated successfully, but these errors were encountered: