pub struct DiffDocument {
pub commit: Option<Commit>,
pub files: Vec<FileDiff>,
}Expand description
A complete unified diff document.
Fields§
§commit: Option<Commit>Commit preamble before the first diff --git section, if present.
files: Vec<FileDiff>File diffs in input order.
Implementations§
Source§impl DiffDocument
impl DiffDocument
Source§impl DiffDocument
impl DiffDocument
Sourcepub fn for_hunks(file: &FileDiff, hunks: impl IntoIterator<Item = Hunk>) -> Self
pub fn for_hunks(file: &FileDiff, hunks: impl IntoIterator<Item = Hunk>) -> Self
Returns a single-file document with the given hunks, suitable for
git apply. The preamble is dropped.
Trait Implementations§
Source§impl Clone for DiffDocument
impl Clone for DiffDocument
Source§fn clone(&self) -> DiffDocument
fn clone(&self) -> DiffDocument
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DiffDocument
impl Debug for DiffDocument
Source§impl Decode for DiffDocument
impl Decode for DiffDocument
Source§fn decode(input: &mut impl BufRead) -> Result<Self, DecodeError>
fn decode(input: &mut impl BufRead) -> Result<Self, DecodeError>
Reads a full diff document from the input stream.
Source§fn decode_bytes(input: &[u8]) -> Result<Self, DecodeError>
fn decode_bytes(input: &[u8]) -> Result<Self, DecodeError>
Decodes a diff document from raw bytes.
Non-UTF-8 bytes are replaced with U+FFFD and ANSI escape sequences are stripped before parsing, so output from colored Git pipes round-trips without caller-side preprocessing.
Source§fn try_decode(input: &mut impl BufRead) -> Result<Option<Self>, DecodeError>
fn try_decode(input: &mut impl BufRead) -> Result<Option<Self>, DecodeError>
Reads and decodes a value, returning
Ok(None) at clean end-of-input.
Anything else, including a partial value followed by EOF surfaces as
Err.Source§fn decode_str(input: &str) -> Result<Self, DecodeError>
fn decode_str(input: &str) -> Result<Self, DecodeError>
Decodes a value from a UTF-8 string.
Source§impl Default for DiffDocument
impl Default for DiffDocument
Source§fn default() -> DiffDocument
fn default() -> DiffDocument
Returns the “default value” for a type. Read more
Source§impl Encode for DiffDocument
impl Encode for DiffDocument
impl Eq for DiffDocument
Source§impl PartialEq for DiffDocument
impl PartialEq for DiffDocument
impl StructuralPartialEq for DiffDocument
Auto Trait Implementations§
impl Freeze for DiffDocument
impl RefUnwindSafe for DiffDocument
impl Send for DiffDocument
impl Sync for DiffDocument
impl Unpin for DiffDocument
impl UnsafeUnpin for DiffDocument
impl UnwindSafe for DiffDocument
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