pub struct TextDiff { /* private fields */ }Expand description
A line-level diff of two texts.
use rich_ext::diff::TextDiff;
let diff = TextDiff::new("a\nb\nc\n", "a\nB\nc\n");
assert_eq!(diff.stats(), (1, 1));
assert_eq!(
diff.unified("old", "new"),
"--- old\n+++ new\n@@ -1,3 +1,3 @@\n a\n-b\n+B\n c\n"
);Implementations§
Source§impl TextDiff
impl TextDiff
Sourcepub fn new(old: &str, new: &str) -> Self
pub fn new(old: &str, new: &str) -> Self
Diff old against new line by line. A line’s terminator is part of
it, so a missing final newline is a change.
Sourcepub fn context(self, lines: usize) -> Self
pub fn context(self, lines: usize) -> Self
Unchanged lines shown around each change (default 3).
Sourcepub fn context_lines(&self) -> usize
pub fn context_lines(&self) -> usize
The configured context.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextDiff
impl RefUnwindSafe for TextDiff
impl Send for TextDiff
impl Sync for TextDiff
impl Unpin for TextDiff
impl UnsafeUnpin for TextDiff
impl UnwindSafe for TextDiff
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more