Skip to content

Instantly share code, notes, and snippets.

@gf3
Created May 29, 2019
Embed
What would you like to do?
error[E0507]: cannot move out of borrowed content
extern crate unidiff;
use unidiff::PatchSet; // http://messense.github.io/unidiff-rs/unidiff/struct.PatchSet.html
pub struct Printer {
patch_set: PatchSet,
}
impl Printer {
pub fn new(source: &str) -> Self {
let mut patch_set = PatchSet::new();
patch_set
.parse(source)
.ok()
.expect("Error parsing source diff");
Printer {
patch_set,
}
}
fn write_patches(&self, output: &mut dyn fmt::Write) {
for patched_file in &self.patch_set {
// ^^^^^^^^^^^^^^ cannot move out of borrowed content
// ...do something with `patched_file`
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment