diff --git a/CHANGELOG.md b/CHANGELOG.md index c2bcae1..d7d3a5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ This release has an [MSRV] of 1.82. - `Image` now stores the alpha as an `f32` ([#65][] by [@waywardmonkeys][]) - Use `color` crate. See below for details ([#63][] by [@waywardmonkeys][]) +- `ColorStopsSource::collect_stops` now consumes `self` ([#87][] by [@waywardmonkeys][]) ### Removed @@ -93,6 +94,7 @@ This release has an [MSRV] of 1.70. [#72]: https://github.com/linebender/peniko/pull/72 [#77]: https://github.com/linebender/peniko/pull/77 [#82]: https://github.com/linebender/peniko/pull/82 +[#87]: https://github.com/linebender/peniko/pull/87 [@dfrg]: https://github.com/dfrg [@DJMcNab]: https://github.com/DJMcNab diff --git a/src/gradient.rs b/src/gradient.rs index 81b69af..3623a38 100644 --- a/src/gradient.rs +++ b/src/gradient.rs @@ -332,15 +332,15 @@ impl Gradient { /// Trait for types that represent a source of color stops. pub trait ColorStopsSource { /// Append the stops represented within `self` into `stops`. - fn collect_stops(&self, stops: &mut ColorStops); + fn collect_stops(self, stops: &mut ColorStops); } impl ColorStopsSource for &'_ [T] where T: Into + Copy, { - fn collect_stops(&self, stops: &mut ColorStops) { - for &stop in *self { + fn collect_stops(self, stops: &mut ColorStops) { + for &stop in self { stops.push(stop.into()); } } @@ -350,15 +350,15 @@ impl ColorStopsSource for [T; N] where T: Into + Copy, { - fn collect_stops(&self, stops: &mut ColorStops) { - for stop in *self { + fn collect_stops(self, stops: &mut ColorStops) { + for &stop in &self { stops.push(stop.into()); } } } impl ColorStopsSource for &'_ [AlphaColor] { - fn collect_stops(&self, stops: &mut ColorStops) { + fn collect_stops(self, stops: &mut ColorStops) { if !self.is_empty() { let denom = (self.len() - 1).max(1) as f32; stops.extend(self.iter().enumerate().map(|(i, c)| ColorStop { @@ -370,7 +370,7 @@ impl ColorStopsSource for &'_ [AlphaColor] { } impl ColorStopsSource for &'_ [DynamicColor] { - fn collect_stops(&self, stops: &mut ColorStops) { + fn collect_stops(self, stops: &mut ColorStops) { if !self.is_empty() { let denom = (self.len() - 1).max(1) as f32; stops.extend(self.iter().enumerate().map(|(i, c)| ColorStop { @@ -382,7 +382,7 @@ impl ColorStopsSource for &'_ [DynamicColor] { } impl ColorStopsSource for &'_ [OpaqueColor] { - fn collect_stops(&self, stops: &mut ColorStops) { + fn collect_stops(self, stops: &mut ColorStops) { if !self.is_empty() { let denom = (self.len() - 1).max(1) as f32; stops.extend(self.iter().enumerate().map(|(i, c)| ColorStop { @@ -394,17 +394,17 @@ impl ColorStopsSource for &'_ [OpaqueColor] { } impl ColorStopsSource for [AlphaColor; N] { - fn collect_stops(&self, stops: &mut ColorStops) { + fn collect_stops(self, stops: &mut ColorStops) { (&self[..]).collect_stops(stops); } } impl ColorStopsSource for [DynamicColor; N] { - fn collect_stops(&self, stops: &mut ColorStops) { + fn collect_stops(self, stops: &mut ColorStops) { (&self[..]).collect_stops(stops); } } impl ColorStopsSource for [OpaqueColor; N] { - fn collect_stops(&self, stops: &mut ColorStops) { + fn collect_stops(self, stops: &mut ColorStops) { (&self[..]).collect_stops(stops); } }