pub struct Hunk<'a>(pub Vec<Line<'a>>);
Expand description
A grouping of consecutive edit lines for a document
Every line in a hunk must be consecutive and in ascending order.
Tuple Fields§
§0: Vec<Line<'a>>
Implementations§
Source§impl<'a> Hunk<'a>
impl<'a> Hunk<'a>
Sourcepub fn first_line(&self) -> Option<usize>
pub fn first_line(&self) -> Option<usize>
Returns the first line number of the hunk
This will return None if the internal vector is empty
Sourcepub fn last_line(&self) -> Option<usize>
pub fn last_line(&self) -> Option<usize>
Returns the last line number of the hunk
This will return None if the internal vector is empty
Sourcepub fn can_push_back(&self, entry: &Entry<'a>) -> Result<(), HunkInsertionError>
pub fn can_push_back(&self, entry: &Entry<'a>) -> Result<(), HunkInsertionError>
Returns whether an entry can be pushed onto the current hunk.
This method is exposed so users can check if the push back operation would fail. This is useful if you want to avoid needing to do extra copies in case an incoming entry is can’t be added to the entry and you don’t want to have to deal with copying the entry for the next hunk.
This returns a result with the specific reason the entry couldn’t be inserted.
Sourcepub fn push_back(
&mut self,
entry: &'a Entry<'a>,
) -> Result<(), HunkInsertionError>
pub fn push_back( &mut self, entry: &'a Entry<'a>, ) -> Result<(), HunkInsertionError>
Append an entry to a hunk.
Entries can only be appended in ascending order (first to last). It is an error to append entries out of order. For example, you can’t insert an entry on line 1 after inserting an entry on line 5.