summaryrefslogtreecommitdiff
path: root/src/geom/sides.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/geom/sides.rs')
-rw-r--r--src/geom/sides.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/geom/sides.rs b/src/geom/sides.rs
index f214a1bf..555bbd62 100644
--- a/src/geom/sides.rs
+++ b/src/geom/sides.rs
@@ -45,6 +45,19 @@ impl<T> Sides<T> {
}
}
+ /// Zip two instances into an instance.
+ pub fn zip<F, V, W>(self, other: Sides<V>, mut f: F) -> Sides<W>
+ where
+ F: FnMut(T, V, Side) -> W,
+ {
+ Sides {
+ left: f(self.left, other.left, Side::Left),
+ top: f(self.top, other.top, Side::Top),
+ right: f(self.right, other.right, Side::Right),
+ bottom: f(self.bottom, other.bottom, Side::Bottom),
+ }
+ }
+
/// Returns an iterator over the sides.
pub fn iter(&self) -> impl Iterator<Item = &T> {
[&self.left, &self.top, &self.right, &self.bottom].into_iter()