From 0d3ca813198f90264d03002aca88fa13a7f35dd9 Mon Sep 17 00:00:00 2001 From: Love Billenius Date: Tue, 7 Jan 2025 17:25:02 +0100 Subject: [PATCH] func ref --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index af5e5b8..dbf4ef8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -82,12 +82,12 @@ async fn main() -> ExitCode { }); } - if cli.compact { - serde_json::to_string(&json_values) + let to_string_json = if cli.compact { + serde_json::to_string } else { - serde_json::to_string_pretty(&json_values) - } - .expect("Failed to parse content as JSON") + serde_json::to_string_pretty + }; + to_string_json(&json_values).expect("Failed to parse content as JSON") } FormatOption::Plain => parsed .iter()