summaryrefslogtreecommitdiff
path: root/src/model/styles.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-21 16:19:46 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-21 16:19:46 +0100
commit31f904a2c406953cbce334e02b37a712b9b9d016 (patch)
treec23f6e063864d97afb9b3d58c10ce4c2877106c5 /src/model/styles.rs
parent4af7b9118c5ce612b3d9d7dd06118ce23b731d9c (diff)
Split up and document shapes
Diffstat (limited to 'src/model/styles.rs')
-rw-r--r--src/model/styles.rs68
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
}
}