From 32b6a3d1109d839efde3cc03cbf5990bd272c95e Mon Sep 17 00:00:00 2001 From: aviac Date: Mon, 22 Jan 2024 09:11:24 +0100 Subject: [PATCH] chore(cleanup): consolidate `writeln`s Authored-by: Aviac --- generator/src/main.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 0796fbb..4e56d5e 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -1066,18 +1066,21 @@ fn simple_query_array( ) -> eyre::Result { let mut out = String::new(); - writeln!(&mut out)?; - writeln!(&mut out, "if !{name}.is_empty() {{")?; - writeln!(&mut out, "for item in {name} {{")?; - writeln!(&mut out, "write!(f, \"{}=\")?;", param.name)?; - out.push_str(item_pusher); - out.push('\n'); - writeln!(&mut out, "if i < {name}.len() - 1 {{")?; - writeln!(&mut out, "s.push('{sep}')")?; - writeln!(&mut out, "}}")?; - writeln!(&mut out, "}}")?; - writeln!(&mut out, "write!(f, '&')?;")?; - writeln!(&mut out, "}}")?; + writeln!( + &mut out, + " +if !{name}.is_empty() {{ + for item in {name} {{ + write!(f, \"{}=\")?; + {item_pusher} + if i < {name}.len() - 1 {{ + write!(f, '{sep}')?; + }} + }} + write!(f, '&')?; +}}", + param.name + )?; Ok(out) }