From 8d8e142337c3fe3ef0daec088b68a2f0888157d9 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 28 Jan 2026 18:52:16 +0100 Subject: [PATCH] nihav_core/formats: more idiomatic NAChannelMap::find_channel_id() --- nihav-core/src/formats.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nihav-core/src/formats.rs b/nihav-core/src/formats.rs index 80f8c78..4d6b906 100644 --- a/nihav-core/src/formats.rs +++ b/nihav-core/src/formats.rs @@ -292,11 +292,8 @@ impl NAChannelMap { self.ids[idx] } /// Tries to find position of the channel with requested type. - pub fn find_channel_id(&self, t: NAChannelType) -> Option { - for i in 0..self.ids.len() { - if self.ids[i] as i32 == t as i32 { return Some(i as u8); } - } - None + pub fn find_channel_id(&self, t: NAChannelType) -> Option { + (0..self.ids.len()).find(|&i| self.ids[i] as i32 == t as i32) } /// Creates a new `NAChannelMap` using the channel mapping flags from WAVE format. pub fn from_ms_mapping(chmap: u32) -> Self { -- 2.39.5