Struct similar::Change [−][src]
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]
fn from(change: Change<'s, T>) -> InlineChange<'s, T>
[src]
impl<'s, T: Hash + ?Sized> Hash for Change<'s, T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'s, T: Ord + ?Sized> Ord for Change<'s, T>
[src]
fn cmp(&self, other: &Change<'s, T>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[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]
fn partial_cmp(&self, other: &Change<'s, T>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[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,
T: RefUnwindSafe,
impl<'s, T: ?Sized> Send for Change<'s, T> where
T: Sync,
T: Sync,
impl<'s, T: ?Sized> Sync for Change<'s, T> where
T: Sync,
T: Sync,
impl<'s, T: ?Sized> Unpin for Change<'s, T>
impl<'s, T: ?Sized> UnwindSafe for Change<'s, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,