#[non_exhaustive]pub enum PatchFormat {
Unified,
Markdown,
Conflict,
Unknown,
}Expand description
Identifies the syntactic format of a patch content string.
This enum is returned by detect_patch() and used internally by
parse_auto() to determine which parsing strategy to apply.
It distinguishes between raw diffs (commonly output by git diff), diffs wrapped
in Markdown code blocks (commonly output by LLMs), and conflict marker blocks
(used in merge conflicts or specific AI suggestions).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Unified
A standard Unified Diff format.
This format is characterized by file headers starting with --- and +++,
or hunk headers starting with @@.
§Example
--- a/file.rs
+++ b/file.rs
@@ -1,3 +1,3 @@
fn main() {
- println!("Old");
+ println!("New");
}Markdown
A Markdown file containing diff code blocks.
This format is characterized by the presence of code fences (e.g., ```diff)
containing patch data. mpatch will extract and parse the content inside these blocks.
§Example
Here is the fix for your issue:
```diff
--- a/src/main.rs
+++ b/src/main.rs
@@ -1 +1 @@
-old_function();
+new_function();
```Conflict
A file containing Conflict Markers.
This format is characterized by the specific markers <<<<, ====, and >>>>.
It is commonly found in Git merge conflicts or AI code suggestions that use
this format to denote “before” and “after” states without full diff headers.
§Example
fn calculate() {
<<<<
return x + y;
====
return x * y;
>>>>
}Unknown
The format could not be determined.
The content did not contain any recognizable signatures (such as diff headers, markdown fences, or conflict markers).
Trait Implementations§
Source§impl Clone for PatchFormat
impl Clone for PatchFormat
Source§fn clone(&self) -> PatchFormat
fn clone(&self) -> PatchFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PatchFormat
impl Debug for PatchFormat
Source§impl PartialEq for PatchFormat
impl PartialEq for PatchFormat
impl Copy for PatchFormat
impl Eq for PatchFormat
impl StructuralPartialEq for PatchFormat
Auto Trait Implementations§
impl Freeze for PatchFormat
impl RefUnwindSafe for PatchFormat
impl Send for PatchFormat
impl Sync for PatchFormat
impl Unpin for PatchFormat
impl UnsafeUnpin for PatchFormat
impl UnwindSafe for PatchFormat
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§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>
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>
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