Struct unidiff::Hunk [] [src]

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]

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

fn added(&self) -> usize

Count of lines added

fn removed(&self) -> usize

Count of lines removed

fn is_valid(&self) -> bool

Is this hunk valid

fn source_lines(&self) -> Vec<Line>

Lines from source file

fn target_lines(&self) -> Vec<Line>

Lines from target file

fn append(&mut self, line: Line)

Append new line into hunk

fn len(&self) -> usize

Count of lines in this hunk

fn is_empty(&self) -> bool

Is this hunk empty

Trait Implementations

impl Hash for Hunk
[src]

fn hash<__H: Hasher>(&self, __arg_0: &mut __H)

Feeds this value into the state given, updating the hasher as necessary.

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0

Feeds a slice of this type into the state provided.

impl Eq for Hunk
[src]

impl PartialEq for Hunk
[src]

fn eq(&self, __arg_0: &Hunk) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Hunk) -> bool

This method tests for !=.

impl Clone for Hunk
[src]

fn clone(&self) -> Hunk

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl Debug for Hunk
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Display for Hunk
[src]

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.

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?

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

impl Index<usize> for Hunk
[src]

type Output = Line

The returned type after indexing

fn index(&self, idx: usize) -> &Line

The method for the indexing (Foo[Bar]) operation

impl IndexMut<usize> for Hunk
[src]

fn index_mut(&mut self, index: usize) -> &mut Line

The method for the indexing (Foo[Bar]) operation