pub struct FileDiff {
pub old_path: Option<String>,
pub new_path: String,
pub is_new: bool,
pub is_rename: bool,
pub added: BTreeSet<u32>,
pub removed: BTreeSet<u32>,
/* private fields */
}Expand description
Per-file diff information.
Fields§
§old_path: Option<String>Old-side (base) path. Differs from new_path on a rename; None for an
added file.
new_path: StringNew-side (head) path.
is_new: boolWhether the file is newly added in head.
is_rename: boolWhether the file was renamed (and possibly modified).
added: BTreeSet<u32>New-side line numbers added or modified by the diff.
removed: BTreeSet<u32>Old-side line numbers removed by the diff.
Implementations§
Source§impl FileDiff
impl FileDiff
Sourcepub fn new(
new_path: impl Into<String>,
old_path: Option<String>,
is_new: bool,
is_rename: bool,
added: BTreeSet<u32>,
removed: BTreeSet<u32>,
) -> Self
pub fn new( new_path: impl Into<String>, old_path: Option<String>, is_new: bool, is_rename: bool, added: BTreeSet<u32>, removed: BTreeSet<u32>, ) -> Self
Builds a FileDiff with only added/removed line sets and no hunk
alignment. Used to construct diffs programmatically and in tests; the
git2-driven path uses DiffModel::from_diff which also records hunks.
Sourcepub fn map_base_to_head(&self, old_line: u32) -> Option<u32>
pub fn map_base_to_head(&self, old_line: u32) -> Option<u32>
Maps an unchanged base-side line to its head-side line number.
Returns None when the base line was removed or modified (i.e. it has no
unchanged counterpart in head). Context lines inside hunks use the exact
pairs git2 reported; lines outside every hunk use the cumulative hunk
offset.
Trait Implementations§
Auto Trait Implementations§
impl Freeze 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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