#[non_exhaustive]pub struct FileDiff {
pub path: String,
pub lines: Vec<DiffLine>,
pub has_changes: bool,
pub missing_newline_at: Vec<usize>,
}Expand description
Result of diffing two files
Construct with FileDiff::new; the struct is #[non_exhaustive] so
fields can be added without breaking downstream crates again.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.path: String§lines: Vec<DiffLine>§has_changes: bool§missing_newline_at: Vec<usize>Indices into lines whose content was the final line of its side and
carried no newline terminator (at most one per side, so at most two).
The line strings themselves are always terminator-free, so this is the
only record of that information; a faithful renderer emits
NO_NEWLINE_MARKER right after each of these lines.
Implementations§
Source§impl FileDiff
impl FileDiff
Sourcepub fn to_unified(&self) -> String
pub fn to_unified(&self) -> String
Format the diff as a unified diff string with context lines (like git diff)
Sourcepub fn to_unified_with_context(&self, context: usize) -> String
pub fn to_unified_with_context(&self, context: usize) -> String
Format the diff as a unified diff string with a custom number of context lines
Sourcepub fn to_unified_with_sides(
&self,
context: usize,
old_exists: bool,
new_exists: bool,
) -> String
pub fn to_unified_with_sides( &self, context: usize, old_exists: bool, new_exists: bool, ) -> String
Like FileDiff::to_unified_with_context, but naming a side that
does not exist (an added file’s old side, a deleted file’s new side)
as /dev/null, so applicators create or delete the file instead of
leaving an empty one behind. See unified_side_headers.
Trait Implementations§
Auto Trait Implementations§
impl Forget for FileDiff
impl Freeze for FileDiff
impl Move for FileDiff
impl RefUnwindSafe for FileDiff
impl Send for FileDiff
impl Sync for FileDiff
impl Unpin for FileDiff
impl UnsafeUnpin for FileDiff
impl UnwindSafe for FileDiff
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more