Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Implement Sum trait for Pixels (#44809)

Nathan Sobo26b261a33645
diff --git a/crates/gpui/src/geometry.rs b/crates/gpui/src/geometry.rs
index f466624dfb9..fc735ba5e0e 100644
--- a/crates/gpui/src/geometry.rs
+++ b/crates/gpui/src/geometry.rs
@@ -2648,6 +2648,18 @@ impl Debug for Pixels {
}
}
+impl std::iter::Sum for Pixels {
+ fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
+ iter.fold(Self::ZERO, |a, b| a + b)
+ }
+}
+
+impl<'a> std::iter::Sum<&'a Pixels> for Pixels {
+ fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self {
+ iter.fold(Self::ZERO, |a, b| a + *b)
+ }
+}
+
impl TryFrom<&'_ str> for Pixels {
type Error = anyhow::Error;