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
structFoo{something:Option<u32>,bar:u32,}fnmain(){let a = Foo{something:Some(1),bar:2,};ifletFoo{something:Some(something), .. } = a {println!("{}", something);}}
rustfmt formats the if let as
ifletFoo{something:Some(something),
..
} = a
{println!("{}", something);}
which looks rather unfortunate...
Should probably keep the original form in this case?
The text was updated successfully, but these errors were encountered:
Also I leave the configuration default, which means control_brace_style should be AlwaysSameLine, however it pushes the brace to the next line here, which seems like a bug?
control_brace_style only applies to control flows whose pattern consist of a single line. IIRC, if the pattern consists of multiple lines, then rustfmt will put the opening brace on the next line.
The same behavior is applied to match arms (or matches! macro, probably any pattern context we can think of).
This actually controlled by setting struct_lit_width (eg. a value of 50 instead of default 28 is enough get the result expected by @upsuper in his example).
However I still think it would make sense to provide a separate settings for actual struct literals and patterns (patterns being usually less readable if they don't fit in a single line, I think this last particular issue make it hard to use advanced pattern matching on struct enum variants with default rustfmt settings).
Given the following code:
rustfmt formats the
if let
aswhich looks rather unfortunate...
Should probably keep the original form in this case?
The text was updated successfully, but these errors were encountered: