Enum similar::algorithms::DiffOp[][src]

pub enum DiffOp {
    Equal {
        old_index: usize,
        new_index: usize,
        len: usize,
    },
    Delete {
        old_index: usize,
        old_len: usize,
        new_index: usize,
    },
    Insert {
        old_index: usize,
        new_index: usize,
        new_len: usize,
    },
    Replace {
        old_index: usize,
        old_len: usize,
        new_index: usize,
        new_len: usize,
    },
}

Utility enum to capture a diff operation.

This is used by Capture.

Variants

Equal

A segment is equal (see DiffHook::equal)

Fields of Equal

old_index: usizenew_index: usizelen: usize
Delete

A segment was deleted (see DiffHook::delete)

Fields of Delete

old_index: usizeold_len: usizenew_index: usize
Insert

A segment was inserted (see DiffHook::insert)

Fields of Insert

old_index: usizenew_index: usizenew_len: usize
Replace

A segment was replaced (see DiffHook::replace)

Fields of Replace

old_index: usizeold_len: usizenew_index: usizenew_len: usize

Implementations

impl DiffOp[src]

pub fn tag(self) -> DiffTag[src]

Returns the tag of the operation.

pub fn old_range(&self) -> Range<usize>[src]

Returns the old range.

pub fn new_range(&self) -> Range<usize>[src]

Returns the new range.

pub fn as_tag_tuple(&self) -> (DiffTag, Range<usize>, Range<usize>)[src]

Transform the op into a tuple of diff tag and ranges.

This is useful when operating on slices. The returned format is (tag, i1..i2, j1..j2):

  • Replace: a[i1..i2] should be replaced by b[j1..j2]
  • Delete: a[i1..i2] should be deleted (j1 == j2 in this case).
  • Insert: b[j1..j2] should be inserted at a[i1..i2] (i1 == i2 in this case).
  • Equal: a[i1..i2] is equal to b[j1..j2].

pub fn apply_to_hook<D: DiffHook>(&self, d: &mut D) -> Result<(), D::Error>[src]

Apply this operation to a diff hook.

Trait Implementations

impl Clone for DiffOp[src]

impl Copy for DiffOp[src]

impl Debug for DiffOp[src]

impl Eq for DiffOp[src]

impl Hash for DiffOp[src]

impl PartialEq<DiffOp> for DiffOp[src]

impl StructuralEq for DiffOp[src]

impl StructuralPartialEq for DiffOp[src]

Auto Trait Implementations

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<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.