From f64539de1f0acbb2246f4f2094f1be3b8aea9b0f Mon Sep 17 00:00:00 2001 From: gennyble Date: Sun, 14 Jan 2024 07:43:13 -0600 Subject: colorsquash: elide lifetimes for clippy --- src/selection.rs | 10 ++++++---- 1 file 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; + // wanted Into here but rustc got mad about vtable building + // because we store this as Box in Squasher and it's builder + fn select(&mut self, max_colors: usize, image: ImageData) -> Vec; } 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 { + fn select(&mut self, max_colours: usize, image: ImageData) -> Vec { let sorted = Self::unique_and_sort(image); let tolerance = (self.tolerance / 100.0) * 765.0; let mut selected_colors: Vec = 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 { - let ImageData(rgb) = image.into(); + fn select(&mut self, max_colors: usize, image: ImageData) -> Vec { + let ImageData(rgb) = image; let kmean = KMeans::new( rgb.as_bytes() -- cgit 1.4.1-3-g733a5