From de057ab0411cfddb40f07f3b23633f9176aa4aed Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Thu, 24 Oct 2024 12:30:05 +0100 Subject: [PATCH] refactor: try simplifying the condition logic --- crates/fmt/src/formatter.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index f36802f79d5a..6bb814e23269 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -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(¶ms, ",", params_multiline)?;