use crate::{ChunkSummary, TextDimension, TextSummary}; use std::ops::{Add, AddAssign, Sub, SubAssign}; #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Unclipped(pub T); impl From for Unclipped { fn from(value: T) -> Self { Unclipped(value) } } impl<'a, T: sum_tree::Dimension<'a, ChunkSummary>> sum_tree::Dimension<'a, ChunkSummary> for Unclipped { fn add_summary(&mut self, summary: &'a ChunkSummary, _: &()) { self.0.add_summary(summary, &()); } } impl TextDimension for Unclipped { fn from_text_summary(summary: &TextSummary) -> Self { Unclipped(T::from_text_summary(summary)) } fn add_assign(&mut self, other: &Self) { TextDimension::add_assign(&mut self.0, &other.0); } } impl> Add> for Unclipped { type Output = Unclipped; fn add(self, rhs: Unclipped) -> Self::Output { Unclipped(self.0 + rhs.0) } } impl> Sub> for Unclipped { type Output = Unclipped; fn sub(self, rhs: Unclipped) -> Self::Output { Unclipped(self.0 - rhs.0) } } impl> AddAssign> for Unclipped { fn add_assign(&mut self, rhs: Unclipped) { self.0 += rhs.0; } } impl> SubAssign> for Unclipped { fn sub_assign(&mut self, rhs: Unclipped) { self.0 -= rhs.0; } }