pub struct Diff { /* private fields */ }Expand description
One file’s change: the unified diff text (the wire) and its hunks (the model).
Implementations§
Source§impl Diff
impl Diff
Sourcepub fn new(path: &Path, before: &str, after: &str) -> Self
pub fn new(path: &Path, before: &str, after: &str) -> Self
A diff whose before and after headers name the same path.
Sourcepub fn between(
old_path: &Path,
new_path: &Path,
before: &str,
after: &str,
) -> Self
pub fn between( old_path: &Path, new_path: &Path, before: &str, after: &str, ) -> Self
The diff of before → after, its hunks read straight from similar.
Sourcepub fn opening(&self, line: u32) -> usize
pub fn opening(&self, line: u32) -> usize
The index of the hunk opening at or before 1-based old-file line;
the first when the line falls before them all.
Sourcepub fn lines(&self) -> impl Iterator<Item = Line> + '_
pub fn lines(&self) -> impl Iterator<Item = Line> + '_
The whole diff as display lines: each hunk’s header, then its lines
with their +/-/space marker.
Sourcepub fn lines_from(&self, line: u32) -> impl Iterator<Item = Line> + '_
pub fn lines_from(&self, line: u32) -> impl Iterator<Item = Line> + '_
The display lines from the hunk opening at or before 1-based line.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Diff
impl<'de> Deserialize<'de> for Diff
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Diff
Source§impl From<String> for Diff
The text alone: the hunks a deserialized diff never had are left empty,
which is fine because only Serialize crosses a wire.
impl From<String> for Diff
The text alone: the hunks a deserialized diff never had are left empty,
which is fine because only Serialize crosses a wire.
impl StructuralPartialEq for Diff
Auto Trait Implementations§
impl Freeze for Diff
impl RefUnwindSafe for Diff
impl Send for Diff
impl Sync for Diff
impl Unpin for Diff
impl UnsafeUnpin for Diff
impl UnwindSafe for Diff
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more