Add blanket implementation for (D1, D2) when they impl `Dimension`

Antonio Scandurra created

Change summary

zed/src/editor/buffer.rs | 11 -----------
zed/src/sum_tree.rs      | 12 ++++++++++++
2 files changed, 12 insertions(+), 11 deletions(-)

Detailed changes

zed/src/editor/buffer.rs 🔗

@@ -2128,17 +2128,6 @@ impl<'a> sum_tree::SeekDimension<'a, FragmentSummary> for VersionedOffset {
     }
 }
 
-impl<'a, T, U> sum_tree::Dimension<'a, FragmentSummary> for (T, U)
-where
-    T: sum_tree::Dimension<'a, FragmentSummary>,
-    U: sum_tree::Dimension<'a, FragmentSummary>,
-{
-    fn add_summary(&mut self, summary: &'a FragmentSummary, cx: &Option<time::Global>) {
-        self.0.add_summary(summary, cx);
-        self.1.add_summary(summary, cx);
-    }
-}
-
 impl Operation {
     fn replica_id(&self) -> ReplicaId {
         self.lamport_timestamp().replica_id

zed/src/sum_tree.rs 🔗

@@ -36,6 +36,18 @@ impl<'a, T: Summary> Dimension<'a, T> for () {
     fn add_summary(&mut self, _: &'a T, _: &T::Context) {}
 }
 
+impl<'a, S, D1, D2> Dimension<'a, S> for (D1, D2)
+where
+    S: Summary,
+    D1: Dimension<'a, S>,
+    D2: Dimension<'a, S>,
+{
+    fn add_summary(&mut self, summary: &'a S, cx: &S::Context) {
+        self.0.add_summary(summary, cx);
+        self.1.add_summary(summary, cx);
+    }
+}
+
 pub trait SeekDimension<'a, T: Summary>: Dimension<'a, T> {
     fn cmp(&self, other: &Self, cx: &T::Context) -> Ordering;
 }