From: Kostya Shishkov Date: Wed, 28 Jan 2026 17:52:16 +0000 (+0100) Subject: nihav_core/formats: more idiomatic NAChannelMap::find_channel_id() X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=8d8e142337c3fe3ef0daec088b68a2f0888157d9;p=nihav.git nihav_core/formats: more idiomatic NAChannelMap::find_channel_id() --- 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 {