Struct Diff

Source
pub struct Diff { /* private fields */ }

Implementations§

Source§

impl Diff

Source

pub fn postprocess_with( &mut self, before: &[Token], after: &[Token], heuristic: impl SliderHeuristic, )

Source

pub fn postprocess_with_heuristic<T>( &mut self, input: &InternedInput<T>, heuristic: impl SliderHeuristic, )

Source§

impl Diff

Source

pub fn unified_diff<'a, P: UnifiedDiffPrinter, T: Hash + Eq>( &'a self, printer: &'a P, config: UnifiedDiffConfig, input: &'a InternedInput<T>, ) -> UnifiedDiff<'a, P>

Source

pub fn unified_diff_with<'a, P: UnifiedDiffPrinter>( &'a self, printer: &'a P, config: UnifiedDiffConfig, before: &'a [Token], after: &'a [Token], ) -> UnifiedDiff<'a, P>

Source§

impl Diff

Source

pub fn compute<T>(algorithm: Algorithm, input: &InternedInput<T>) -> Diff

Computes an edit-script that transforms input.before into input.after using the specified algorithm

Source

pub fn compute_with( &mut self, algorithm: Algorithm, before: &[Token], after: &[Token], num_tokens: u32, )

Computes an edit-script that transforms before into after using the specified algorithm.

Source

pub fn count_additions(&self) -> u32

Source

pub fn count_removals(&self) -> u32

Source

pub fn is_removed(&self, token_idx: u32) -> bool

Source

pub fn is_added(&self, token_idx: u32) -> bool

Source

pub fn postprocess_no_heuristic<T>(&mut self, input: &InternedInput<T>)

Postprocesses the diff to make it more human readable. Certain bvhunks have an amigous placement (event in a minimal diff) where they can move downward or upward by removing a token (line) at the start and adding one at the end (or the other way around). The postprocessing adjust these hunks according to a coulple rules:

  • Always merge multiple hunks if possible.
  • Always try to create a single MODIFY hunk instead of multiple disjoint ADDED/REMOVED hunks
  • Move sliders as far down as possible.
Source

pub fn postprocess_lines<T: AsRef<[u8]>>(&mut self, input: &InternedInput<T>)

Postprocesses the diff to make it more human readable. Certain bvhunks have an amigous placement (event in a minimal diff) where they can move downward or upward by removing a token (line) at the start and adding one at the end (or the other way around). The postprocessing adjust these hunks according to a coulple rules:

  • Always merge multiple hunks if possible.
  • Always try to create a single MODIFY hunk instead of multiple disjoint ADDED/REMOVED hunks
  • based on a lines indentation level heuristically compute the most intutive location to split lines.
  • Move sliders as far down as possible.
Source

pub fn hunks(&self) -> HunkIter<'_>

An iterator that yields the changed hunks in this diff

Trait Implementations§

Source§

impl Debug for Diff

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Diff

Source§

fn default() -> Diff

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Diff

§

impl RefUnwindSafe for Diff

§

impl Send for Diff

§

impl Sync for Diff

§

impl Unpin for Diff

§

impl UnwindSafe for Diff

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.