pub struct Change<T> { /* private fields */ }
Expand description
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§
source§impl<'s, T: DiffableStr + ?Sized> Change<&'s T>
impl<'s, T: DiffableStr + ?Sized> Change<&'s T>
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.
sourcepub fn to_string_lossy(&self) -> Cow<'s, str>
pub fn to_string_lossy(&self) -> Cow<'s, str>
Returns the value (lossy) decoded as utf-8 string.
sourcepub fn missing_newline(&self) -> bool
pub fn missing_newline(&self) -> bool
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.
source§impl<T: Clone> Change<T>
impl<T: Clone> Change<T>
These methods are available for all change types.
sourcepub fn value(&self) -> T
pub fn value(&self) -> T
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§
source§impl<'s, T: DiffableStr + ?Sized> From<Change<&'s T>> for InlineChange<'s, T>
impl<'s, T: DiffableStr + ?Sized> From<Change<&'s T>> for InlineChange<'s, T>
source§impl<T: Ord> Ord for Change<T>
impl<T: Ord> Ord for Change<T>
source§impl<T: PartialEq> PartialEq for Change<T>
impl<T: PartialEq> PartialEq for Change<T>
source§impl<T: PartialOrd> PartialOrd for Change<T>
impl<T: PartialOrd> PartialOrd for Change<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more