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

This commit is contained in:
Antonio Scandurra 2021-06-04 12:36:38 +02:00
parent f016400ddc
commit 3b9d760f2b
2 changed files with 12 additions and 11 deletions

View file

@ -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

View file

@ -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;
}