From 1078e77688187e8979499c93cab3ac5eedab80a9 Mon Sep 17 00:00:00 2001 From: Vladimir Bauer Date: Thu, 25 Jan 2024 16:26:20 +0500 Subject: [PATCH] trim_end: no need for mut record parameter --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2fd9afc..6509384 100644 --- a/src/main.rs +++ b/src/main.rs @@ -126,11 +126,11 @@ fn uniq_cmd(delim: u8, include_trailing: bool) -> Result<()> { Ok(()) } -fn trim_end(mut record: &[u8], delim: u8) -> &[u8] { - if record.last_byte() == Some(delim) { - record = &record[..record.len() - 1]; +fn trim_end(record: &[u8], delim: u8) -> &[u8] { + match record.last_byte() { + Some(b) if b == delim => &record[..record.len() - 1], + _ => record, } - record } fn try_main() -> Result<()> {