[][src]Struct diffy::Patch

pub struct Patch<'a, T: ToOwned + ?Sized> { /* fields omitted */ }

Representation of all the differences between two files

Implementations

impl<'a, T: ToOwned + ?Sized> Patch<'a, T>[src]

pub fn original(&self) -> Option<&T>[src]

Return the name of the old file

pub fn modified(&self) -> Option<&T>[src]

Return the name of the new file

pub fn hunks(&self) -> &[Hunk<T>][src]

Returns the hunks in the patch

impl<'_, T: AsRef<[u8]> + ToOwned + ?Sized> Patch<'_, T>[src]

pub fn to_bytes(&self) -> Vec<u8>[src]

Convert a Patch into bytes

This is the equivalent of the to_string function but for potentially non-utf8 patches.

impl<'a> Patch<'a, str>[src]

pub fn from_str(s: &'a str) -> Result<Patch<'a, str>, ParsePatchError>[src]

Parse a Patch from a string

use diffy::Patch;

let s = "\
--- a/ideals
+++ b/ideals
@@ -1,4 +1,6 @@
 First:
     Life before death,
     strength before weakness,
     journey before destination.
+Second:
+    I will protect those who cannot protect themselves.
";

let patch = Patch::from_str(s).unwrap();

impl<'a> Patch<'a, [u8]>[src]

pub fn from_bytes(s: &'a [u8]) -> Result<Patch<'a, [u8]>, ParsePatchError>[src]

Parse a Patch from bytes

Trait Implementations

impl<'_, T: ToOwned + ?Sized> Clone for Patch<'_, T>[src]

impl<'_, T: ?Sized, O> Debug for Patch<'_, T> where
    T: ToOwned<Owned = O> + Debug,
    O: Borrow<T> + Debug
[src]

impl<'_> Display for Patch<'_, str>[src]

impl<'a, T: Eq + ToOwned + ?Sized> Eq for Patch<'a, T>[src]

impl<'a, T: PartialEq + ToOwned + ?Sized> PartialEq<Patch<'a, T>> for Patch<'a, T>[src]

impl<'a, T: ToOwned + ?Sized> StructuralEq for Patch<'a, T>[src]

impl<'a, T: ToOwned + ?Sized> StructuralPartialEq for Patch<'a, T>[src]

Auto Trait Implementations

impl<'a, T: ?Sized> RefUnwindSafe for Patch<'a, T> where
    T: RefUnwindSafe,
    <T as ToOwned>::Owned: RefUnwindSafe

impl<'a, T: ?Sized> Send for Patch<'a, T> where
    T: Sync,
    <T as ToOwned>::Owned: Send

impl<'a, T: ?Sized> Sync for Patch<'a, T> where
    T: Sync,
    <T as ToOwned>::Owned: Sync

impl<'a, T: ?Sized> Unpin for Patch<'a, T> where
    <T as ToOwned>::Owned: Unpin

impl<'a, T: ?Sized> UnwindSafe for Patch<'a, T> where
    T: RefUnwindSafe,
    <T as ToOwned>::Owned: UnwindSafe

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.