summaryrefslogtreecommitdiff
path: root/src/geom/sides.rs
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2022-05-03 11:40:27 +0200
committerMartin Haug <mhaug@live.de>2022-05-03 12:59:41 +0200
commit6a8a0ec6ec8bb8cf346ee0dd2c45ddcfbee7fbe6 (patch)
tree0d8716d2fa0c01a2319bb84be0283253bc6490fe /src/geom/sides.rs
parent33213abe7dfcb8d8065faadd2f5b72ec4b718af1 (diff)
Code Review: Heap is Stack. Unsafe is Good.
Spaghetti Code is Style.
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()