[][src]Struct unidiff::Hunk

pub struct Hunk {
    pub source_start: usize,
    pub source_length: usize,
    pub target_start: usize,
    pub target_length: usize,
    pub section_header: String,
    // some fields omitted
}

Each of the modified blocks of a file

You can iterate over it to get Lines.

Fields

source_start: usize

Source file starting line number

source_length: usize

Source file changes length

target_start: usize

Target file starting line number

target_length: usize

Target file changes length

section_header: String

Section header

Methods

impl Hunk[src]

pub fn new<T: Into<String>>(
    source_start: usize,
    source_length: usize,
    target_start: usize,
    target_length: usize,
    section_header: T
) -> Hunk
[src]

pub fn added(&self) -> usize[src]

Count of lines added

pub fn removed(&self) -> usize[src]

Count of lines removed

pub fn is_valid(&self) -> bool[src]

Is this hunk valid

pub fn source_lines(&self) -> Vec<Line>[src]

Lines from source file

pub fn target_lines(&self) -> Vec<Line>[src]

Lines from target file

pub fn append(&mut self, line: Line)[src]

Append new line into hunk

pub fn len(&self) -> usize[src]

Count of lines in this hunk

pub fn is_empty(&self) -> bool[src]

Is this hunk empty

pub fn lines(&self) -> &[Line][src]

Lines in this hunk

pub fn lines_mut(&mut self) -> &mut [Line][src]

Trait Implementations

impl Clone for Hunk[src]

impl Debug for Hunk[src]

impl Display for Hunk[src]

impl Eq for Hunk[src]

impl Hash for Hunk[src]

impl Index<usize> for Hunk[src]

type Output = Line

The returned type after indexing.

impl IndexMut<usize> for Hunk[src]

impl IntoIterator for Hunk[src]

type Item = Line

The type of the elements being iterated over.

type IntoIter = IntoIter<Line>

Which kind of iterator are we turning this into?

impl PartialEq<Hunk> for Hunk[src]

impl StructuralEq for Hunk[src]

impl StructuralPartialEq for Hunk[src]

Auto Trait Implementations

impl RefUnwindSafe for Hunk

impl Send for Hunk

impl Sync for Hunk

impl Unpin for Hunk

impl UnwindSafe for Hunk

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.