Skip to main content

java_diff_utils_rs/text/delta_merge/
inline_delta_merge_info.rs

1//! Holds the information required to merge deltas originating from an inline diff.
2
3use crate::patch::delta::Delta;
4
5/// Holds the information required to merge deltas originating from an inline diff.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct InlineDeltaMergeInfo<T = String> {
8    deltas: Vec<Delta<T>>,
9    orig_list: Vec<T>,
10    rev_list: Vec<T>,
11}
12
13impl<T> InlineDeltaMergeInfo<T> {
14    /// Constructs a new `InlineDeltaMergeInfo` instance.
15    pub fn new(deltas: Vec<Delta<T>>, orig_list: Vec<T>, rev_list: Vec<T>) -> Self {
16        Self {
17            deltas,
18            orig_list,
19            rev_list,
20        }
21    }
22
23    /// Returns a slice of the deltas.
24    pub fn deltas(&self) -> &[Delta<T>] {
25        &self.deltas
26    }
27
28    /// Returns a slice of the original text elements.
29    pub fn orig_list(&self) -> &[T] {
30        &self.orig_list
31    }
32
33    /// Returns a slice of the revised text elements.
34    pub fn rev_list(&self) -> &[T] {
35        &self.rev_list
36    }
37
38    /// Consumes self and returns the inner tuple of `(deltas, orig_list, rev_list)`.
39    pub fn into_parts(self) -> (Vec<Delta<T>>, Vec<T>, Vec<T>) {
40        (self.deltas, self.orig_list, self.rev_list)
41    }
42}