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>
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.
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>
These methods are available for all change types.
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.