Skip to main content

DiffOptions

Struct DiffOptions 

Source
#[non_exhaustive]
pub struct DiffOptions { pub context_lines: usize, pub inter_hunk_context: usize, pub algorithm: DiffAlgorithm, pub indent_heuristic: bool, pub renames: RenameDetection, pub filter: Option<DiffFilter>, pub whitespace: WhitespaceMode, pub word_level_inline: bool, pub function_context: bool, /* private fields */ }
Expand description

Line-diff options shared by structured output, log patches, and benchmarks.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§context_lines: usize

Unchanged context lines around each change (Git -U, default 3).

§inter_hunk_context: usize

--inter-hunk-context (default 0).

§algorithm: DiffAlgorithm

Line diff algorithm.

§indent_heuristic: bool

Apply Git’s indent heuristic when generating hunks.

§renames: RenameDetection

Rename detection for tree diffs.

§filter: Option<DiffFilter>

--diff-filter status selection (applied after rename detection).

§whitespace: WhitespaceMode

Whitespace comparison rules for line diffs.

§word_level_inline: bool

When false, skip intra-line word emphasis (line-level hunks only).

§function_context: bool

Expand hunks to enclosing function boundaries (git diff -W).

Implementations§

Source§

impl DiffOptions

Source

pub fn with_context_lines(self, context_lines: usize) -> Self

Builder-style update of context lines (-U).

Source

pub fn with_inter_hunk_context(self, inter_hunk_context: usize) -> Self

Builder-style update of inter-hunk context.

Source

pub fn with_algorithm(self, algorithm: DiffAlgorithm) -> Self

Builder-style update of the line diff algorithm.

Source

pub fn with_indent_heuristic(self, indent_heuristic: bool) -> Self

Builder-style update of the indent heuristic flag.

Source

pub fn with_renames(self, renames: RenameDetection) -> Self

Builder-style update of rename detection.

Source

pub fn with_filter(self, filter: Option<DiffFilter>) -> Self

Builder-style update of diff status filter.

Source

pub fn rename_similarity_threshold(&self) -> Option<u32>

Similarity percent for rename detection, or None when RenameDetection::Off.

Source

pub fn rename_threshold_u32(&self) -> u32

u32 threshold for super::apply_rename_detection_to_diff_entries and related APIs.

Source

pub fn with_word_level_inline(self, word_level_inline: bool) -> Self

Builder-style update of word-level inline emphasis.

Source

pub fn with_whitespace(self, whitespace: WhitespaceMode) -> Self

Builder-style update of whitespace comparison rules.

Source

pub fn cap_word_level_inline_for_changed_files( self, changed_files: usize, ) -> Self

Turn off word-level inline when changed_files exceeds WORD_LEVEL_INLINE_MAX_CHANGED_FILES.

Source

pub fn from_config(config: &ConfigSet) -> Self

Read diff.algorithm, diff.context, diff.interHunkContext, diff.indentHeuristic, and diff.renames from repository config.

Source

pub fn resolve_indent_heuristic( config: &ConfigSet, cli_indent_heuristic: bool, cli_no_indent_heuristic: bool, ) -> bool

Resolve indent heuristic with optional CLI overrides (log/diff plumbing).

Trait Implementations§

Source§

impl Clone for DiffOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DiffOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DiffOptions

Source§

fn default() -> Self

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

impl PartialEq for DiffOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.