Struct similar::Change[][src]

pub struct Change<'s, T: ?Sized> { /* fields omitted */ }

Represents the expanded DiffOp change.

This type is returned from DiffOp::iter_changes and TextDiff::iter_changes.

It exists so that it’s more convenient to work with textual differences as the underlying DiffOp encodes a group of changes.

This type has additional methods that are only available for types implementing DiffableStr.

Implementations

impl<'s, T: DiffableStr + ?Sized> Change<'s, T>[src]

The text interface can produce changes over DiffableStr implementing values. As those are generic interfaces for different types of strings utility methods to make working with standard rust strings more enjoyable.

pub fn as_str(&self) -> Option<&'s str>[src]

Returns the value as string if it is utf-8.

pub fn to_string_lossy(&self) -> Cow<'s, str>[src]

Returns the value (lossy) decoded as utf-8 string.

pub fn missing_newline(&self) -> bool[src]

Returns true if this change does not end in a newline and must be followed up by one if line based diffs are used.

The std::fmt::Display implementation of Change will automatically insert a newline after the value if this is true.

impl<'s, T: ?Sized> Change<'s, T>[src]

These methods are available for all change types.

pub fn tag(&self) -> ChangeTag[src]

Returns the change tag.

pub fn old_index(&self) -> Option<usize>[src]

Returns the old index if available.

pub fn new_index(&self) -> Option<usize>[src]

Returns the new index if available.

pub fn value(&self) -> &'s T[src]

Returns the underlying changed value.

Depending on the type of the underlying crate::text::DiffableStr this value is more or less useful. If you always want to have a utf-8 string it’s best to use the Change::as_str and Change::to_string_lossy methods.

Trait Implementations

impl<'s, T: Clone + ?Sized> Clone for Change<'s, T>[src]

impl<'s, T: Copy + ?Sized> Copy for Change<'s, T>[src]

impl<'s, T: Debug + ?Sized> Debug for Change<'s, T>[src]

impl<'s, T: DiffableStr + ?Sized> Display for Change<'s, T>[src]

impl<'s, T: Eq + ?Sized> Eq for Change<'s, T>[src]

impl<'s, T: DiffableStr + ?Sized> From<Change<'s, T>> for InlineChange<'s, T>[src]

impl<'s, T: Hash + ?Sized> Hash for Change<'s, T>[src]

impl<'s, T: Ord + ?Sized> Ord for Change<'s, T>[src]

impl<'s, T: PartialEq + ?Sized> PartialEq<Change<'s, T>> for Change<'s, T>[src]

impl<'s, T: PartialOrd + ?Sized> PartialOrd<Change<'s, T>> for Change<'s, T>[src]

impl<'s, T: ?Sized> StructuralEq for Change<'s, T>[src]

impl<'s, T: ?Sized> StructuralPartialEq for Change<'s, T>[src]

Auto Trait Implementations

impl<'s, T: ?Sized> RefUnwindSafe for Change<'s, T> where
    T: RefUnwindSafe

impl<'s, T: ?Sized> Send for Change<'s, T> where
    T: Sync

impl<'s, T: ?Sized> Sync for Change<'s, T> where
    T: Sync

impl<'s, T: ?Sized> Unpin for Change<'s, T>

impl<'s, T: ?Sized> UnwindSafe for Change<'s, T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.