pub struct TextDiff<'a> { /* private fields */ }Expand description
Text difference between two strings. ANSI-styled when printed.
§Display representation
You can specify additional padding at the start of compared lines
via alignment specifiers. For example, {:>4} will insert 4 spaces at the start of each line.
§Examples
use styled_str::{StyledString, TextDiff};
let diff = TextDiff::new("Hello, world", "Hello world!");
let diff_str = StyledString::from_ansi(&format!("{diff:>4}"))?;
assert_eq!(
diff_str.text().trim(),
"Diff < left / right > :\n\
< Hello, world\n\
> Hello world!"
);
assert!(!diff_str.as_str().is_plain());Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for TextDiff<'a>
impl<'a> RefUnwindSafe for TextDiff<'a>
impl<'a> Send for TextDiff<'a>
impl<'a> Sync for TextDiff<'a>
impl<'a> Unpin for TextDiff<'a>
impl<'a> UnwindSafe for TextDiff<'a>
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