Struct git_diff::blob::sink::Counter

source ·
pub struct Counter<T> {
    pub removals: u32,
    pub insertions: u32,
    pub wrapped: T,
}
Expand description

A Sink which wraps a different sink and counts the number of removed and inserted tokens.

Fields§

§removals: u32

Total number of recorded inserted tokens. Computed by summing the lengths of the after subsequences pass to process_change.

§insertions: u32

Total number of recorded inserted tokens. Computed by summing the lengths of the after subsequences pass to process_change.

§wrapped: T

The Sink for which the counter records tokens. All calls to process_change are forwarded to the sink by the counter. After finish is called, this field contains the output returned by the finish method of the wrapped Sink

Implementations§

source§

impl<S> Counter<S>where S: Sink,

source

pub fn new(sink: S) -> Counter<S>

source§

impl<T> Counter<T>

source

pub fn total(&self) -> usize

Trait Implementations§

source§

impl Default for Counter<()>

source§

fn default() -> Counter<()>

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

impl<S> Sink for Counter<S>where S: Sink,

§

type Out = Counter<<S as Sink>::Out>

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 file. A change is a continous subsequence of tokens before that needs to be replaced by a different contious subsequence of tokens after to construct the seconds file from the first. Read more
source§

fn finish(self) -> <Counter<S> as Sink>::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<T> RefUnwindSafe for Counter<T>where T: RefUnwindSafe,

§

impl<T> Send for Counter<T>where T: Send,

§

impl<T> Sync for Counter<T>where T: Sync,

§

impl<T> Unpin for Counter<T>where T: Unpin,

§

impl<T> UnwindSafe for Counter<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.