diff --git a/crates/text/src/patch.rs b/crates/text/src/patch.rs index 91a0761017..a21f1125ec 100644 --- a/crates/text/src/patch.rs +++ b/crates/text/src/patch.rs @@ -9,7 +9,8 @@ pub struct Patch(Vec>); impl Patch where - T: Clone + T: 'static + + Clone + Copy + Ord + Sub @@ -41,9 +42,9 @@ where self.0 } - pub fn compose(&self, other: &Self) -> Self { + pub fn compose(&self, new_edits_iter: impl IntoIterator>) -> Self { let mut old_edits_iter = self.0.iter().cloned().peekable(); - let mut new_edits_iter = other.0.iter().cloned().peekable(); + let mut new_edits_iter = new_edits_iter.into_iter().peekable(); let mut composed = Patch(Vec::new()); let mut old_start = T::default(); @@ -200,6 +201,15 @@ where } } +impl<'a, T: Clone> IntoIterator for &'a Patch { + type Item = Edit; + type IntoIter = std::iter::Cloned>>; + + fn into_iter(self) -> Self::IntoIter { + self.0.iter().cloned() + } +} + #[cfg(test)] mod tests { use super::*;