about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--gifed/src/block/palette.rs11
1 files 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<u8> {
-		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.