pub struct Hunk {
pub old_start: u32,
pub old_lines: u32,
pub new_start: u32,
pub new_lines: u32,
pub lines: Vec<DiffLine>,
}Expand description
A “hunk” is a standard Git concept: a contiguous group of changed lines within a single file, together with a few surrounding unchanged (context) lines for orientation.
When a file has changes in multiple separate regions, Git produces one hunk per region rather than one giant diff. For example, if lines 10-12 and lines 50-55 were modified, that file’s diff would contain two hunks.
The line numbers refer to positions in the old (before) and new (after) versions of the file:
old_start/old_lines: where this hunk begins and how many lines it spans in the original file.new_start/new_lines: the same for the modified file.
These correspond to the @@ -old_start,old_lines +new_start,new_lines @@
header you see in unified diff output.
Fields§
§old_start: u32§old_lines: u32§new_start: u32§new_lines: u32§lines: Vec<DiffLine>The individual lines in this hunk (context, additions, and deletions).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hunk
impl RefUnwindSafe for Hunk
impl Send for Hunk
impl Sync for Hunk
impl Unpin for Hunk
impl UnsafeUnpin for Hunk
impl UnwindSafe for Hunk
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
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>
Converts
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>
Converts
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