Skip to main content

SliderHeuristic

Trait SliderHeuristic 

Source
pub trait SliderHeuristic {
    // Required method
    fn best_slider_end(
        &mut self,
        tokens: &[Token],
        hunk: Range<u32>,
        earliest_end: u32,
    ) -> u32;
}
Available on crate feature blob only.
Expand description

A trait for heuristics that determine the best position for ambiguous diff hunks.

During postprocessing, some hunks can be moved up or down without changing the minimal nature of the diff. This trait allows customizing the logic for choosing the optimal position for such hunks.

Required Methods§

Source

fn best_slider_end( &mut self, tokens: &[Token], hunk: Range<u32>, earliest_end: u32, ) -> u32

Determines the best ending position for a hunk that can be slid.

§Parameters
  • tokens - The token sequence being diffed
  • hunk - The range representing the current hunk position
  • earliest_end - The earliest valid ending position for the hunk
§Returns

The preferred ending position for the hunk

Implementors§

Source§

impl SliderHeuristic for NoSliderHeuristic

Source§

impl<F> SliderHeuristic for F
where F: FnMut(&[Token], Range<u32>, u32) -> u32,

Source§

impl<IndentOfToken> SliderHeuristic for IndentHeuristic<IndentOfToken>
where IndentOfToken: Fn(Token) -> IndentLevel,