Struct similar::InlineChange
source · pub struct InlineChange<'s, T: DiffableStr + ?Sized> { /* private fields */ }
Expand description
Represents the expanded textual change with inline highlights.
This is like Change
but with inline highlight info.
Implementations§
source§impl<'s, T: DiffableStr + ?Sized> InlineChange<'s, T>
impl<'s, T: DiffableStr + ?Sized> InlineChange<'s, T>
sourcepub fn values(&self) -> &[(bool, &'s T)]
pub fn values(&self) -> &[(bool, &'s T)]
Returns the changed values.
Each item is a tuple in the form (emphasized, value)
where emphasized
is true if it should be highlighted as an inline diff.
Depending on the type of the underlying DiffableStr
this value is
more or less useful. If you always want to have a utf-8 string it’s
better to use the InlineChange::iter_strings_lossy
method.
sourcepub fn iter_strings_lossy(&self) -> impl Iterator<Item = (bool, Cow<'_, str>)>
pub fn iter_strings_lossy(&self) -> impl Iterator<Item = (bool, Cow<'_, str>)>
Iterates over all (potentially lossy) utf-8 decoded values.
Each item is a tuple in the form (emphasized, value)
where emphasized
is true if it should be highlighted as an inline diff.
By default, words are split by whitespace, which results in coarser diff.
For example: "f(x) y"
is tokenized as ["f(x)", "y"]
.
If you want it to be tokenized instead as ["f(", "x", ")"]
,
you should enable the "unicode"
flag.
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.
Trait Implementations§
source§impl<'s, T: Clone + DiffableStr + ?Sized> Clone for InlineChange<'s, T>
impl<'s, T: Clone + DiffableStr + ?Sized> Clone for InlineChange<'s, T>
source§fn clone(&self) -> InlineChange<'s, T>
fn clone(&self) -> InlineChange<'s, T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'s, T: Debug + DiffableStr + ?Sized> Debug for InlineChange<'s, T>
impl<'s, T: Debug + DiffableStr + ?Sized> Debug for InlineChange<'s, T>
source§impl<'s, T: DiffableStr + ?Sized> Display for InlineChange<'s, T>
impl<'s, T: DiffableStr + ?Sized> Display for InlineChange<'s, T>
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<'s, T: Hash + DiffableStr + ?Sized> Hash for InlineChange<'s, T>
impl<'s, T: Hash + DiffableStr + ?Sized> Hash for InlineChange<'s, T>
source§impl<'s, T: Ord + DiffableStr + ?Sized> Ord for InlineChange<'s, T>
impl<'s, T: Ord + DiffableStr + ?Sized> Ord for InlineChange<'s, T>
source§fn cmp(&self, other: &InlineChange<'s, T>) -> Ordering
fn cmp(&self, other: &InlineChange<'s, T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<'s, T: PartialEq + DiffableStr + ?Sized> PartialEq for InlineChange<'s, T>
impl<'s, T: PartialEq + DiffableStr + ?Sized> PartialEq for InlineChange<'s, T>
source§fn eq(&self, other: &InlineChange<'s, T>) -> bool
fn eq(&self, other: &InlineChange<'s, T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'s, T: PartialOrd + DiffableStr + ?Sized> PartialOrd for InlineChange<'s, T>
impl<'s, T: PartialOrd + DiffableStr + ?Sized> PartialOrd for InlineChange<'s, T>
source§fn partial_cmp(&self, other: &InlineChange<'s, T>) -> Option<Ordering>
fn partial_cmp(&self, other: &InlineChange<'s, T>) -> Option<Ordering>
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 moreimpl<'s, T: Eq + DiffableStr + ?Sized> Eq for InlineChange<'s, T>
impl<'s, T: DiffableStr + ?Sized> StructuralPartialEq for InlineChange<'s, T>
Auto Trait Implementations§
impl<'s, T> Freeze for InlineChange<'s, T>where
T: ?Sized,
impl<'s, T> RefUnwindSafe for InlineChange<'s, T>where
T: RefUnwindSafe + ?Sized,
impl<'s, T> Send for InlineChange<'s, T>
impl<'s, T> Sync for InlineChange<'s, T>
impl<'s, T> Unpin for InlineChange<'s, T>where
T: ?Sized,
impl<'s, T> UnwindSafe for InlineChange<'s, T>where
T: RefUnwindSafe + ?Sized,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)