From 3b9d760f2b65b1c77698ad7148e0dd894ba1706c Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 4 Jun 2021 12:36:38 +0200 Subject: [PATCH] Add blanket implementation for (D1, D2) when they impl `Dimension` --- zed/src/editor/buffer.rs | 11 ----------- zed/src/sum_tree.rs | 12 ++++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/zed/src/editor/buffer.rs b/zed/src/editor/buffer.rs index 82e6818bfc..fe43bf2e67 100644 --- a/zed/src/editor/buffer.rs +++ b/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) { - self.0.add_summary(summary, cx); - self.1.add_summary(summary, cx); - } -} - impl Operation { fn replica_id(&self) -> ReplicaId { self.lamport_timestamp().replica_id diff --git a/zed/src/sum_tree.rs b/zed/src/sum_tree.rs index 35b9183376..48338d4a57 100644 --- a/zed/src/sum_tree.rs +++ b/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; }