Skip to main content

IndentHeuristic

Struct IndentHeuristic 

Source
pub struct IndentHeuristic<IndentOfToken> { /* private fields */ }
Available on crate feature blob only.
Expand description

A slider heuristic that uses indentation levels to determine the best hunk position.

This heuristic analyzes the indentation of lines surrounding potential hunk positions and chooses the position that results in the most intuitive diff for human readers. It’s particularly effective for code and other indented text.

Implementations§

Source§

impl<IndentOfToken> IndentHeuristic<IndentOfToken>

Source

pub fn new(indent_of_token: IndentOfToken) -> IndentHeuristic<IndentOfToken>

Creates a new IndentHeuristic with the given indentation function.

§Parameters
  • indent_of_token - A function that takes a token and returns its indentation level

Trait Implementations§

Source§

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

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. Read more

Auto Trait Implementations§

§

impl<IndentOfToken> Freeze for IndentHeuristic<IndentOfToken>
where IndentOfToken: Freeze,

§

impl<IndentOfToken> RefUnwindSafe for IndentHeuristic<IndentOfToken>
where IndentOfToken: RefUnwindSafe,

§

impl<IndentOfToken> Send for IndentHeuristic<IndentOfToken>
where IndentOfToken: Send,

§

impl<IndentOfToken> Sync for IndentHeuristic<IndentOfToken>
where IndentOfToken: Sync,

§

impl<IndentOfToken> Unpin for IndentHeuristic<IndentOfToken>
where IndentOfToken: Unpin,

§

impl<IndentOfToken> UnsafeUnpin for IndentHeuristic<IndentOfToken>
where IndentOfToken: UnsafeUnpin,

§

impl<IndentOfToken> UnwindSafe for IndentHeuristic<IndentOfToken>
where IndentOfToken: UnwindSafe,

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.