From eed1868c122f3953699ee0b820e2dcaa9db842b3 Mon Sep 17 00:00:00 2001 From: Devon Sawatsky Date: Sun, 31 Dec 2023 15:19:45 -0800 Subject: silly rewrite of from_color to make it less readable and less lines --- gifed/src/block/palette.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gifed/src/block/palette.rs b/gifed/src/block/palette.rs index b1414b4..f49442f 100644 --- a/gifed/src/block/palette.rs +++ b/gifed/src/block/palette.rs @@ -49,12 +49,11 @@ impl Palette { } pub fn from_color(&self, color: Color) -> Option { - for (i, &c) in self.table.iter().enumerate() { - if c == color { - return Some(i as u8); - } - } - None + self.table + .iter() + .enumerate() + .find(|(i, c)| **c == color) + .map(|(i, c)| i as u8) } /// How many padding bytes we need to write. -- cgit 1.4.1-3-g733a5