Struct exec_diff::Diff

source ·
pub struct Diff<Left, Right> {
    pub left: Left,
    pub right: Right,
    pub color: Color,
    pub unified: bool,
}
Expand description

The diff executor.

This is a wrapper around the GNU diff command.

Fields§

§left: Left

Value on the left.

§right: Right

Value on the right.

§color: Color

Whether to include ANSI color in the diff.

§unified: bool

Whether to use the unified diff format.

Implementations§

source§

impl<Left, Right> Diff<Left, Right>

source

pub const fn new(left: Left, right: Right) -> Self

Initialize a diff executor.

source

pub fn left<NewLeft>(self, left: NewLeft) -> Diff<NewLeft, Right>

Set the left value.

source

pub fn right<NewRight>(self, right: NewRight) -> Diff<Left, NewRight>

Set the right value.

source

pub const fn color(self, color: Color) -> Self

Set color mode.

source

pub const fn unified(self, unified: bool) -> Self

Set diff format.

source§

impl<Left, Right> Diff<Left, Right>where Left: AsRef<str>, Right: AsRef<str>,

source

pub fn exec(&self) -> Result<Option<String>, DiffExecError>

Use the GNU diff command to compare two strings.

Return:

  • Err(error) means that the diff command was failed to executed or status > 1
  • Ok(None) means that no diff was found (status = 0).
  • Ok(Some(diff)) means that there was diff (status = 1).
source

pub fn assert_eq(&self)

Assert that two strings are equal.

It will fallback to pretty_assertions if diff is failed to execute.

Trait Implementations§

source§

impl<Left: Clone, Right: Clone> Clone for Diff<Left, Right>

source§

fn clone(&self) -> Diff<Left, Right>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<Left: Debug, Right: Debug> Debug for Diff<Left, Right>

source§

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

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

impl<Left: Copy, Right: Copy> Copy for Diff<Left, Right>

Auto Trait Implementations§

§

impl<Left, Right> RefUnwindSafe for Diff<Left, Right>where Left: RefUnwindSafe, Right: RefUnwindSafe,

§

impl<Left, Right> Send for Diff<Left, Right>where Left: Send, Right: Send,

§

impl<Left, Right> Sync for Diff<Left, Right>where Left: Sync, Right: Sync,

§

impl<Left, Right> Unpin for Diff<Left, Right>where Left: Unpin, Right: Unpin,

§

impl<Left, Right> UnwindSafe for Diff<Left, Right>where Left: UnwindSafe, Right: 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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<X> Pipe for X

source§

fn pipe<Return, Function>(self, f: Function) -> Returnwhere Self: Sized, Function: FnOnce(Self) -> Return,

Apply f to self. Read more
source§

fn pipe_ref<'a, Return, Function>(&'a self, f: Function) -> Returnwhere Function: FnOnce(&'a Self) -> Return,

Apply f to &self. Read more
source§

fn pipe_mut<'a, Return, Function>(&'a mut self, f: Function) -> Returnwhere Function: FnOnce(&'a mut Self) -> Return,

Apply f to &mut self. Read more
source§

fn pipe_as_ref<'a, Param, Return, Function>(&'a self, f: Function) -> Returnwhere Self: AsRef<Param>, Param: 'a + ?Sized, Function: FnOnce(&'a Param) -> Return,

Apply f to &self where f takes a single parameter of type Param and Self implements trait AsRef<Param>. Read more
source§

fn pipe_as_mut<'a, Param, Return, Function>(&'a mut self, f: Function) -> Returnwhere Self: AsMut<Param>, Param: 'a + ?Sized, Function: FnOnce(&'a mut Param) -> Return,

Apply f to &mut self where f takes a single parameter of type Param and Self implements trait AsMut<Param>. Read more
source§

fn pipe_deref<'a, Param, Return, Function>(&'a self, f: Function) -> Returnwhere Self: Deref<Target = Param>, Param: 'a + ?Sized, Function: FnOnce(&'a Param) -> Return,

Apply f to &self where f takes a single parameter of type Param and Self implements trait Deref<Target = Param>. Read more
source§

fn pipe_deref_mut<'a, Param, Return, Function>( &'a mut self, f: Function ) -> Returnwhere Self: DerefMut<Target = Param>, Param: 'a + ?Sized, Function: FnOnce(&'a mut Param) -> Return,

Apply f to &mut self where f takes a single parameter of type Param and Self implements trait [DerefMut<Target = Param>]. Read more
source§

fn pipe_borrow<'a, Param, Return, Function>(&'a self, f: Function) -> Returnwhere Self: Borrow<Param>, Param: 'a + ?Sized, Function: FnOnce(&'a Param) -> Return,

Apply f to &self where f takes a single parameter of type Param and Self implements trait Borrow<Param>. Read more
source§

fn pipe_borrow_mut<'a, Param, Return, Function>( &'a mut self, f: Function ) -> Returnwhere Self: BorrowMut<Param>, Param: 'a + ?Sized, Function: FnOnce(&'a mut Param) -> Return,

Apply f to &mut self where f takes a single parameter of type Param and Self implements trait BorrowMut<Param>. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

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

§

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 Twhere U: TryFrom<T>,

§

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.