diff options
Diffstat (limited to 'src/model/styles.rs')
| -rw-r--r-- | src/model/styles.rs | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/src/model/styles.rs b/src/model/styles.rs index 1eaf5128..e78d83cd 100644 --- a/src/model/styles.rs +++ b/src/model/styles.rs @@ -914,67 +914,79 @@ where } } -impl Fold for Axes<Option<GenAlign>> { - type Output = Axes<GenAlign>; +impl<T> Fold for Axes<Option<T>> +where + T: Fold, +{ + type Output = Axes<T::Output>; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer).map(|(inner, outer)| inner.unwrap_or(outer)) + self.zip(outer).map(|(inner, outer)| match inner { + Some(value) => value.fold(outer), + None => outer, + }) } } -impl<T> Fold for Sides<T> +impl<T> Fold for Sides<Option<T>> where T: Fold, { type Output = Sides<T::Output>; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer).map(|(inner, outer)| inner.fold(outer)) + self.zip(outer).map(|(inner, outer)| match inner { + Some(value) => value.fold(outer), + None => outer, + }) } } -impl Fold for Sides<Option<Rel<Abs>>> { - type Output = Sides<Rel<Abs>>; +impl<T> Fold for Corners<Option<T>> +where + T: Fold, +{ + type Output = Corners<T::Output>; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer).map(|(inner, outer)| inner.unwrap_or(outer)) + self.zip(outer).map(|(inner, outer)| match inner { + Some(value) => value.fold(outer), + None => outer, + }) } } -impl Fold for Sides<Option<Smart<Rel<Length>>>> { - type Output = Sides<Smart<Rel<Length>>>; +impl Fold for PartialStroke<Abs> { + type Output = Self; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer).map(|(inner, outer)| inner.unwrap_or(outer)) + Self { + paint: self.paint.or(outer.paint), + thickness: self.thickness.or(outer.thickness), + } } } -impl<T> Fold for Corners<T> -where - T: Fold, -{ - type Output = Corners<T::Output>; +impl Fold for Rel<Length> { + type Output = Self; - fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer).map(|(inner, outer)| inner.fold(outer)) + fn fold(self, _: Self::Output) -> Self::Output { + self } } -impl Fold for Corners<Option<Rel<Abs>>> { - type Output = Corners<Rel<Abs>>; +impl Fold for Rel<Abs> { + type Output = Self; - fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer).map(|(inner, outer)| inner.unwrap_or(outer)) + fn fold(self, _: Self::Output) -> Self::Output { + self } } -impl Fold for PartialStroke<Abs> { +impl Fold for GenAlign { type Output = Self; - fn fold(self, outer: Self::Output) -> Self::Output { - Self { - paint: self.paint.or(outer.paint), - thickness: self.thickness.or(outer.thickness), - } + fn fold(self, _: Self::Output) -> Self::Output { + self } } |
