From b51d5a20bcb57c058bf0f2dd2510cad645dffbf4 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 7 Aug 2023 00:31:20 +0200 Subject: Add an ‘is_terminal’ predicate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 8ac0223..3aa3ffa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,7 +84,7 @@ fn work() -> Result<(), io::Error> { err!("{e}"); }) }) - .group_by(|b| *b == (b'\0' + b'\n' * !flags.nul as u8)); + .group_by(|b| is_terminal(&flags, b)); let srcs = srcs .into_iter() .filter(|(x, _)| !x) @@ -266,7 +266,7 @@ fn run_multi( err!("{e}"); }) }) - .group_by(|b| *b == (b'\0' + b'\n' * !flags.nul as u8)); + .group_by(|b| is_terminal(flags, b)); groups .into_iter() .filter_map(|(x, y)| match x { @@ -395,3 +395,7 @@ fn copy_and_remove_file_or_dir<'a>( } Ok(()) } + +fn is_terminal(flags: &Flags, b: &u8) -> bool { + *b == (b'\0' + b'\n' * !flags.nul as u8) +} -- cgit v1.2.3