Skip to content

Commit

Permalink
refactor: try simplifying the condition logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Oct 24, 2024
1 parent 5cc3833 commit a364e88
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions crates/fmt/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1640,16 +1640,15 @@ impl<'a, W: Write> Formatter<'a, W> {
)?;
// Write new line if we have only one parameter and params first set,
// or if the function definition is multiline and all params set.
if params.len() == 1 &&
(matches!(
let single_param_multiline = matches!(
fmt.config.multiline_func_header,
MultilineFuncHeaderStyle::ParamsFirst
) || params_multiline &&
matches!(
fmt.config.multiline_func_header,
MultilineFuncHeaderStyle::ParamsFirst
) || params_multiline &&
matches!(
fmt.config.multiline_func_header,
MultilineFuncHeaderStyle::AllParams
))
{
MultilineFuncHeaderStyle::AllParams
);
if params.len() == 1 && single_param_multiline {
writeln!(fmt.buf())?;
}
fmt.write_chunks_separated(&params, ",", params_multiline)?;
Expand Down

0 comments on commit a364e88

Please sign in to comment.