pub fn push_back(&mut self, entry: Entry<'a>) -> Result<(), HunkInsertionError> {
        let incoming_line_idx = entry.reference.start_position().row;

        // Create a new line if the incoming entry is on the next line. This will throw an error
        // if we have an entry on a non-adjacent line or an out-of-order insertion.
        if let Some(last_line) = self.0.back() {
            let last_line_idx = last_line.line_index;

            if incoming_line_idx < last_line_idx {
                return Err(HunkInsertionError::PriorLine {
                    incoming_line: incoming_line_idx,
                    last_line: last_line_idx,
                });
            }

            if incoming_line_idx - last_line_idx > 1 {
                return Err(HunkInsertionError::NonAdjacentHunk {
                    incoming_line: incoming_line_idx,
                    last_line: last_line_idx,
                });
            }

            if incoming_line_idx - last_line_idx == 1 {
                self.0.push_back(Line::new(incoming_line_idx));
            }
        }
        // The lines are empty, we need to add the first one
        else {
            self.0.push_back(Line::new(incoming_line_idx))
        }

        let last_line = self.0.back_mut().unwrap();

        if let Some(&last_entry) = last_line.entries.back() {
            let last_col = last_entry.reference.end_position().column;
            let incoming_col = entry.reference.start_position().column;

            if incoming_col < last_col {
                return Err(HunkInsertionError::PriorColumn {
                    incoming_col,
                    last_col,
                });
            }
        }
        last_line.entries.push_back(entry);
        Ok(())
    }
/// Append an [entry](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.
Append an [entry](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.
Append an [ entry ] ( 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 .
pub fn push_back(&mut self, entry: Entry<'a>) -> Result<(), HunkInsertionError> {
        let incoming_line_idx = entry.reference.start_position().row;
        // Create a new line if the incoming entry is on the next line. This will throw an error
        // if we have an entry on a non-adjacent line or an out-of-order insertion.
        if let Some(last_line) = self.0.back() {
            let last_line_idx = last_line.line_index;
            if incoming_line_idx < last_line_idx {
                return Err(HunkInsertionError::PriorLine {
                    incoming_line: incoming_line_idx,
                    last_line: last_line_idx,
                });
            }
            if incoming_line_idx - last_line_idx > 1 {
                return Err(HunkInsertionError::NonAdjacentHunk {
                    incoming_line: incoming_line_idx,
                    last_line: last_line_idx,
                });
            }
            if incoming_line_idx - last_line_idx == 1 {
                self.0.push_back(Line::new(incoming_line_idx));
            }
        }
        // The lines are empty, we need to add the first one
        else {
            self.0.push_back(Line::new(incoming_line_idx))
        }
        let last_line = self.0.back_mut().unwrap();
        if let Some(&last_entry) = last_line.entries.back() {
            let last_col = last_entry.reference.end_position().column;
            let incoming_col = entry.reference.start_position().column;
            if incoming_col < last_col {
                return Err(HunkInsertionError::PriorColumn {
                    incoming_col,
                    last_col,
                });
            }
        }
        last_line.entries.push_back(entry);
        Ok(())
    }
pub fn push_back ( & mut self , entry : Entry < ' a > ) -> Result < ( ) , HunkInsertionError > { let incoming_line_idx = entry . reference . start_position ( ) . row ; // Create a new line if the incoming entry is on the next line. This will throw an error // if we have an entry on a non-adjacent line or an out-of-order insertion. if let Some ( last_line ) = self . 0 . back ( ) { let last_line_idx = last_line . line_index ; if incoming_line_idx < last_line_idx { return Err ( HunkInsertionError :: PriorLine { incoming_line : incoming_line_idx , last_line : last_line_idx , } ) ; } if incoming_line_idx - last_line_idx > 1 { return Err ( HunkInsertionError :: NonAdjacentHunk { incoming_line : incoming_line_idx , last_line : last_line_idx , } ) ; } if incoming_line_idx - last_line_idx == 1 { self . 0 . push_back ( Line :: new ( incoming_line_idx ) ) ; } } // The lines are empty, we need to add the first one else { self . 0 . push_back ( Line :: new ( incoming_line_idx ) ) } let last_line = self . 0 . back_mut ( ) . unwrap ( ) ; if let Some ( & last_entry ) = last_line . entries . back ( ) { let last_col = last_entry . reference . end_position ( ) . column ; let incoming_col = entry . reference . start_position ( ) . column ; if incoming_col < last_col { return Err ( HunkInsertionError :: PriorColumn { incoming_col , last_col , } ) ; } } last_line . entries . push_back ( entry ) ; Ok ( ( ) ) }
Append an [entry](Entry) to a hunk.
Append an [ entry ] ( Entry ) to a hunk .
&mut self
entry
Entry<'a>
&mut self
entry
Entry<'a>