]> git.nihav.org Git - nihav.git/commitdiff
nihav_core/formats: more idiomatic NAChannelMap::find_channel_id()
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 28 Jan 2026 17:52:16 +0000 (18:52 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 28 Jan 2026 17:52:16 +0000 (18:52 +0100)
nihav-core/src/formats.rs

index 80f8c780e098ea611fe4f03faa01c3d02b83e636..4d6b906cce864df84760518fc21184e8d1cfec9b 100644 (file)
@@ -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<u8> {
-        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<usize> {
+        (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 {