pub struct PatchResult {
pub report: ApplyResult,
pub diff: Option<String>,
}Expand description
The result of an apply_patch_to_file() operation.
This struct is returned when a patch is applied to the filesystem. It contains a detailed report of the outcome for each hunk and, if a dry run was performed, a diff of the proposed changes.
§Example
let dir = tempdir()?;
let file_path = dir.path().join("test.txt");
fs::write(&file_path, "line one\n")?;
let diff = r#"
```diff
--- a/test.txt
+++ b/test.txt
@@ -1 +1 @@
-line one
+line 1
```
"#;
let patch = parse_single_patch(diff)?;
// Perform a dry run to get a diff.
let options = ApplyOptions::dry_run();
let result = apply_patch_to_file(&patch, dir.path(), options)?;
// Check the report.
assert!(result.report.all_applied_cleanly());
// Inspect the generated diff.
assert!(result.diff.is_some());
println!("Proposed changes:\n{}", result.diff.unwrap());Fields§
§report: ApplyResultDetailed results for each hunk within the patch operation.
diff: Option<String>The unified diff of the proposed changes. This is only populated
when dry_run was set to true in ApplyOptions.
Trait Implementations§
Source§impl Clone for PatchResult
impl Clone for PatchResult
Source§fn clone(&self) -> PatchResult
fn clone(&self) -> PatchResult
Returns a duplicate of the value. Read more
1.0.0 · 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 PatchResult
impl Debug for PatchResult
Source§impl PartialEq for PatchResult
impl PartialEq for PatchResult
impl StructuralPartialEq for PatchResult
Auto Trait Implementations§
impl Freeze for PatchResult
impl RefUnwindSafe for PatchResult
impl Send for PatchResult
impl Sync for PatchResult
impl Unpin for PatchResult
impl UnsafeUnpin for PatchResult
impl UnwindSafe for PatchResult
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,
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