about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDevon Sawatsky <novedevo@gmail.com>2023-12-31 15:19:45 -0800
committerDevon Sawatsky <novedevo@gmail.com>2023-12-31 15:19:45 -0800
commiteed1868c122f3953699ee0b820e2dcaa9db842b3 (patch)
tree4b93e9391134f93fc6f631d0e3db158a7ad77699
parent2a39c5e4360303d9565d51d30111ce028a1c960e (diff)
downloadgifed-eed1868c122f3953699ee0b820e2dcaa9db842b3.tar.gz
gifed-eed1868c122f3953699ee0b820e2dcaa9db842b3.zip
silly rewrite of from_color to make it less readable and less lines
-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.