Skip to main content

HunkWordDiff

Trait HunkWordDiff 

Source
pub trait HunkWordDiff {
    // Required methods
    fn push_minus(&mut self, content: &[u8]);
    fn push_plus(&mut self, content: &[u8]);
    fn flush(&mut self, out: &mut Vec<u8>);
    fn emit_context_line(&mut self, out: &mut Vec<u8>, content: &[u8]);
}
Expand description

A hook that renders a single hunk’s body when --word-diff is active.

The renderer feeds the hunk’s tagged lines through this in order (fn_out_consume’s diff_words branch): each removed line is pushed to the minus buffer, each added line to the plus buffer, and a context line flushes the accumulated word diff before emitting the context line itself. The implementor owns the actual word-level rendering and color spans; this keeps the word-diff machinery in the consumer.

Required Methods§

Source

fn push_minus(&mut self, content: &[u8])

Buffer one removed line’s content for the next word-diff flush.

Source

fn push_plus(&mut self, content: &[u8])

Buffer one added line’s content for the next word-diff flush.

Source

fn flush(&mut self, out: &mut Vec<u8>)

Word-diff the accumulated minus/plus buffers into out and reset them.

Source

fn emit_context_line(&mut self, out: &mut Vec<u8>, content: &[u8])

Emit one context line (the --word-diff context style).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§