From dff53d684842432920f3f60825d3d3f40f5063aa Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Sun, 18 Oct 2026 09:59:12 +0900 Subject: [PATCH] stty: simplify cc_to_index --- src/uu/stty/src/stty.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/uu/stty/src/stty.rs b/src/uu/stty/src/stty.rs index 21f66657411..35c8ce1cf12 100644 --- a/src/uu/stty/src/stty.rs +++ b/src/uu/stty/src/stty.rs @@ -619,12 +619,9 @@ fn print_terminal_size( } fn cc_to_index(option: &str) -> Option { - for cc in CONTROL_CHARS { - if option == cc.0 { - return Some(cc.1); - } - } - None + CONTROL_CHARS + .iter() + .find_map(|cc| (cc.0 == option).then_some(cc.1)) } fn string_to_combo(arg: &str) -> Option<&str> {