pub struct FileDiff {
pub old_path: Option<String>,
pub new_path: Option<String>,
pub status: FileStatus,
pub binary: bool,
pub similarity: Option<u8>,
pub old_mode: Option<String>,
pub new_mode: Option<String>,
pub hunks: Vec<Hunk>,
pub header: Vec<String>,
pub coarse: bool,
/* private fields */
}Expand description
The changes to one file.
Fields§
§old_path: Option<String>Path before the change (None for an added file); a/ and b/ prefixes are stripped.
new_path: Option<String>Path after the change (None for a deleted file).
status: FileStatus§binary: boolA binary file: no hunks, only a marker.
similarity: Option<u8>similarity index of a rename or copy, in percent.
old_mode: Option<String>§new_mode: Option<String>§hunks: Vec<Hunk>§header: Vec<String>The header lines as written (diff --git, index, ---, +++, binary data…), without
line breaks; FileDiff::to_patch writes them back verbatim.
coarse: boolThe diff hit its cost cap: correct, but not necessarily the smallest.
Implementations§
Source§impl FileDiff
impl FileDiff
Sourcepub fn from_texts(old: &str, new: &str) -> FileDiff
pub fn from_texts(old: &str, new: &str) -> FileDiff
Diffs two texts line by line with the default options.
Sourcepub fn from_texts_with(old: &str, new: &str, opts: DiffOptions) -> FileDiff
pub fn from_texts_with(old: &str, new: &str, opts: DiffOptions) -> FileDiff
Diffs two texts line by line. The new text is kept, so every Gap is expandable.
Sourcepub fn with_paths(self, old: &str, new: &str) -> FileDiff
pub fn with_paths(self, old: &str, new: &str) -> FileDiff
Sets both paths (and the ---/+++ header lines).
Sourcepub fn with_source(self, new_text: &str) -> FileDiff
pub fn with_source(self, new_text: &str) -> FileDiff
Supplies the full new text of a parsed patch, so its collapsed ranges can be expanded.
Sourcepub fn source_len(&self) -> Option<u32>
pub fn source_len(&self) -> Option<u32>
Number of lines of the new text, when it is known.
Sourcepub fn source_line(&self, new_no: u32) -> Option<&str>
pub fn source_line(&self, new_no: u32) -> Option<&str>
Line new_no (1-based) of the new text, without its line break, when the text is known.