From 002e02f50c5bfebfc69fb1acb86d39a36d96d97d Mon Sep 17 00:00:00 2001 From: Arpit Bhadauria Date: Tue, 28 Nov 2023 09:10:31 +0000 Subject: [PATCH] Fix styling in fmt --- src/uu/fmt/src/linebreak.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/uu/fmt/src/linebreak.rs b/src/uu/fmt/src/linebreak.rs index e5cd1c7be..4a057245b 100644 --- a/src/uu/fmt/src/linebreak.rs +++ b/src/uu/fmt/src/linebreak.rs @@ -60,7 +60,9 @@ pub fn break_lines( let (w, w_len) = match p_words_words.next() { Some(winfo) => (winfo.word, winfo.word_nchars), None => { - return ostream.write_all(b"\n").map_err_context(|| "failed to write output".to_string()); + return ostream + .write_all(b"\n") + .map_err_context(|| "failed to write output".to_string()); } }; // print the init, if it exists, and get its length @@ -108,7 +110,9 @@ fn break_simple<'a, T: Iterator>>( iter.try_fold((args.init_len, false), |l, winfo| { accum_words_simple(args, l, winfo) })?; - args.ostream.write_all(b"\n").map_err_context(|| "failed to write output".to_string()) + args.ostream + .write_all(b"\n") + .map_err_context(|| "failed to write output".to_string()) } fn accum_words_simple<'a>( @@ -210,7 +214,9 @@ fn break_knuth_plass<'a, T: Clone + Iterator>>( fresh = false; write_with_spaces(word, slen, args.ostream)?; } - args.ostream.write_all(b"\n").map_err_context(|| "failed to write output".to_string()) + args.ostream + .write_all(b"\n") + .map_err_context(|| "failed to write output".to_string()) } struct LineBreak<'a> { @@ -369,14 +375,19 @@ fn find_kp_breakpoints<'a, T: Iterator>>( build_best_path(&linebreaks, active_breaks) } -fn build_best_path<'a>(paths: &[LineBreak<'a>], active: &[usize]) -> UResult, bool)>> { +fn build_best_path<'a>( + paths: &[LineBreak<'a>], + active: &[usize], +) -> UResult, bool)>> { let mut breakwords = vec![]; // of the active paths, we select the one with the fewest demerits let mut best_idx = match active.iter().min_by_key(|&&a| paths[a].demerits) { - None => return Err(USimpleError::new( - 1, - "Failed to find a k-p linebreak solution. This should never happen." - )), + None => { + return Err(USimpleError::new( + 1, + "Failed to find a k-p linebreak solution. This should never happen.", + )) + } Some(&s) => s, };