diff --git a/src/color.rs b/src/color.rs index 4c1b768879..ea11d5dacb 100644 --- a/src/color.rs +++ b/src/color.rs @@ -382,19 +382,6 @@ impl Pixel for $ident { } } - fn map2_without_alpha(&self, other: &Self, f: F) -> $ident where F: FnMut(T, T) -> T { - let mut this = (*self).clone(); - this.apply2_without_alpha(other, f); - this - } - - fn apply2_without_alpha(&mut self, other: &$ident, mut f: F) where F: FnMut(T, T) -> T { - const ALPHA: usize = $channels - $alphas; - for (a, &b) in self.0[..ALPHA].iter_mut().zip(other.0[..ALPHA].iter()) { - *a = f(*a, b) - } - } - fn invert(&mut self) { Invert::invert(self) } diff --git a/src/traits.rs b/src/traits.rs index 8b13602407..d5c1b2b7e2 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -377,13 +377,21 @@ pub trait Pixel: Copy + Clone { /// of this pixel and ```other``` pairwise. fn map2_without_alpha(&self, other: &Self, f: F) -> Self where - F: FnMut(Self::Subpixel, Self::Subpixel) -> Self::Subpixel; + F: FnMut(Self::Subpixel, Self::Subpixel) -> Self::Subpixel + { + let mut this = *self; + this.apply2_with_alpha(other, f, |x, _| x); + this + } /// Apply the function ```f``` to each channel except the alpha channel, /// of this pixel and ```other``` pairwise. Works in place. fn apply2_without_alpha(&mut self, other: &Self, f: F) where - F: FnMut(Self::Subpixel, Self::Subpixel) -> Self::Subpixel; + F: FnMut(Self::Subpixel, Self::Subpixel) -> Self::Subpixel + { + self.apply2_with_alpha(other, f, |x, _| x); + } /// Invert this pixel fn invert(&mut self);