Skip to content

Commit

Permalink
chore: optimize text output generation
Browse files Browse the repository at this point in the history
  • Loading branch information
natecox committed Jun 12, 2024
1 parent d3829c3 commit 2b2165b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clap::Parser;
use corrator::{Config, Options};
use directories::ProjectDirs;
use serde::de::DeserializeOwned;
use std::{fs, path::Path};
use std::{fmt::Write, fs, path::Path};

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
Expand Down Expand Up @@ -78,10 +78,10 @@ fn main() {
if let Ok(data) = config.run() {
match args.format.as_str() {
"text" => {
let data: String = data
.into_iter()
.map(|x| format!("{}\n\n", String::from(x)))
.collect();
let data: String = data.into_iter().fold(String::new(), |mut output, b| {
write!(output, "{}\n\n", String::from(b)).expect("Unable to build output text");
output
});
write_results(data, args);
}
"json" => write_results(serde_json::to_string(&data).unwrap(), args),
Expand Down

0 comments on commit 2b2165b

Please sign in to comment.