From 37269c518816add0beaeebeefdb23413e790d38d Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 20 Jun 2026 16:21:30 +0200 Subject: [PATCH] pr: use match instead of if/else chain --- src/uu/pr/src/pr.rs | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 4371e19704..f3c56d77ab 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -1351,24 +1351,20 @@ fn write_columns( for row in table { let indexes = row.len(); for (i, cell) in row.iter().enumerate() { - if cell.is_none() && options.merge_files_print.is_some() { - write_offset_spaces(out, options.offset_spaces)?; - out.write_all( - get_line_for_printing(options, &blank_line, columns, i, line_width, indexes) - .as_bytes(), - )?; - } else if cell.is_none() { - not_found_break = true; - break; - } else if cell.is_some() { - let file_line = cell.unwrap(); - - write_offset_spaces(out, options.offset_spaces)?; - out.write_all( - get_line_for_printing(options, file_line, columns, i, line_width, indexes) - .as_bytes(), - )?; - } + let line_to_print = match cell { + None if options.merge_files_print.is_some() => &blank_line, + None => { + not_found_break = true; + break; + } + Some(file_line) => file_line, + }; + + write_offset_spaces(out, options.offset_spaces)?; + out.write_all( + get_line_for_printing(options, line_to_print, columns, i, line_width, indexes) + .as_bytes(), + )?; } if not_found_break && feed_line_present { break;