Struct UnifiedDiff

Source
pub struct UnifiedDiff<'a, T, D>
where T: Hash + Eq + AsRef<[u8]>, D: ConsumeHunk,
{ /* private fields */ }
Available on crate feature blob only.
Expand description

A Sink that creates a textual diff in the format typically output by git or gnu-diff if the -u option is used, and passes it in full to a consumer.

Implementations§

Source§

impl<'a, T, D> UnifiedDiff<'a, T, D>
where T: Hash + Eq + AsRef<[u8]>, D: ConsumeHunk,

Source

pub fn new( input: &'a InternedInput<T>, consume_hunk: D, newline_separator: NewlineSeparator<'a>, context_size: ContextSize, ) -> Self

Create a new instance to create unified diff using the lines in input, which also must be used when running the diff algorithm. context_size is the amount of lines around each hunk which will be passed to consume_hunk.

consume_hunk is called for each hunk in unified-diff format, as created from each line separated by newline_separator.

Trait Implementations§

Source§

impl<T, D> Sink for UnifiedDiff<'_, T, D>
where T: Hash + Eq + AsRef<[u8]>, D: ConsumeHunk,

Source§

type Out = Result<<D as ConsumeHunk>::Out, Error>

Source§

fn process_change(&mut self, before: Range<u32>, after: Range<u32>)

This method is called whenever a diff algorithm finds a change between the two processed input files. A change is a continuous subsequence of tokens before that needs to be replaced by a different continuous subsequence of tokens after to construct the second file from the first. Read more
Source§

fn finish(self) -> Self::Out

This function is called after all calls to process_change are complete to obtain the final diff result
Source§

fn with_counter(self) -> Counter<Self>

Utility method that constructs a Counter that tracks the total number of inserted and removed tokens in the changes passed to process_change.

Auto Trait Implementations§

§

impl<'a, T, D> Freeze for UnifiedDiff<'a, T, D>
where D: Freeze,

§

impl<'a, T, D> !RefUnwindSafe for UnifiedDiff<'a, T, D>

§

impl<'a, T, D> Send for UnifiedDiff<'a, T, D>
where D: Send, T: Sync,

§

impl<'a, T, D> Sync for UnifiedDiff<'a, T, D>
where D: Sync, T: Sync,

§

impl<'a, T, D> Unpin for UnifiedDiff<'a, T, D>
where D: Unpin,

§

impl<'a, T, D> !UnwindSafe for UnifiedDiff<'a, T, D>

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> Same for T

Source§

type Output = T

Should always be Self
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.