diff options
author | aviac <aviac@mailbox.org> | 2024-01-22 09:11:24 +0100 |
---|---|---|
committer | aviac <aviac@mailbox.org> | 2024-01-22 09:11:24 +0100 |
commit | 32b6a3d1109d839efde3cc03cbf5990bd272c95e (patch) | |
tree | b163008990007ac8b58f102ad8336fb54158c90d | |
parent | feat(definitions): impl `Display` (diff) | |
download | forgejo-api-32b6a3d1109d839efde3cc03cbf5990bd272c95e.tar.xz forgejo-api-32b6a3d1109d839efde3cc03cbf5990bd272c95e.zip |
chore(cleanup): consolidate `writeln`s
Authored-by: Aviac <aviac@mailbox.org>
-rw-r--r-- | generator/src/main.rs | 27 |
1 files 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<String> { 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) } |