about summary refs log tree commit diff
path: root/src/selection.rs
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2024-01-14 07:43:13 -0600
committergennyble <gen@nyble.dev>2024-01-14 07:43:13 -0600
commitf64539de1f0acbb2246f4f2094f1be3b8aea9b0f (patch)
treefd1f1e821f0c28980ec0dbf38bf708f0ba26964b /src/selection.rs
parent8021985c4b38106d9349d319794298699f650040 (diff)
downloadcolorsquash-f64539de1f0acbb2246f4f2094f1be3b8aea9b0f.tar.gz
colorsquash-f64539de1f0acbb2246f4f2094f1be3b8aea9b0f.zip
colorsquash: elide lifetimes for clippy
Diffstat (limited to 'src/selection.rs')
-rw-r--r--src/selection.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/selection.rs b/src/selection.rs
index 8215fbf..1e27ac4 100644
--- a/src/selection.rs
+++ b/src/selection.rs
@@ -10,7 +10,9 @@ use crate::{
 };
 
 pub trait Selector {
-	fn select<'a>(&mut self, max_colors: usize, image: ImageData<'a>) -> Vec<RGB8>;
+	// wanted Into<ImageData> here but rustc got mad about vtable building
+	// because we store this as Box<dyn Selector> in Squasher and it's builder
+	fn select(&mut self, max_colors: usize, image: ImageData) -> Vec<RGB8>;
 }
 
 pub struct SortSelect {
@@ -21,7 +23,7 @@ pub struct SortSelect {
 impl Selector for SortSelect {
 	/// Pick the colors in the palette from a Vec of colors sorted by number
 	/// of times they occur, high to low.
-	fn select<'a>(&mut self, max_colours: usize, image: ImageData<'a>) -> Vec<RGB8> {
+	fn select(&mut self, max_colours: usize, image: ImageData) -> Vec<RGB8> {
 		let sorted = Self::unique_and_sort(image);
 		let tolerance = (self.tolerance / 100.0) * 765.0;
 		let mut selected_colors: Vec<RGB8> = Vec::with_capacity(max_colours);
@@ -107,8 +109,8 @@ pub struct Kmeans;
 
 #[cfg(feature = "kmeans")]
 impl Selector for Kmeans {
-	fn select<'a>(&mut self, max_colors: usize, image: ImageData<'a>) -> Vec<RGB8> {
-		let ImageData(rgb) = image.into();
+	fn select(&mut self, max_colors: usize, image: ImageData) -> Vec<RGB8> {
+		let ImageData(rgb) = image;
 
 		let kmean = KMeans::new(
 			rgb.as_bytes()