Function diffy::apply

source ·
pub fn apply(
    base_image: &str,
    patch: &Patch<'_, str>
) -> Result<String, ApplyError>
Expand description

Apply a Patch to a base image

use diffy::{apply, 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();

let base_image = "\
First:
    Life before death,
    strength before weakness,
    journey before destination.
";

let expected = "\
First:
    Life before death,
    strength before weakness,
    journey before destination.
Second:
    I will protect those who cannot protect themselves.
";

assert_eq!(apply(base_image, &patch).unwrap(), expected);