Skip to content

Commit

Permalink
Replace the text and patch references with the data itself
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgar2017 committed Dec 12, 2018
1 parent faa4cbb commit 9f31126
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "patch-rs"
version = "0.1.0"
version = "0.2.0"
authors = ["hedgar2017 <[email protected]>"]
license = "MIT"
description = "Rust diff implementation"
Expand Down
2 changes: 1 addition & 1 deletion src/bin/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() -> PatchResult<()> {
let text = read_to_vec(file)?;
let patch = fs::read_to_string(patch)?;

let parser = PatchParser::new(&text, &patch);
let parser = PatchParser::new(text, patch);
for s in parser.process()? {
println!("{}", s);
}
Expand Down
12 changes: 6 additions & 6 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use super::error::{PatchErrorKind, PatchResult};

#[derive(Parser)]
#[grammar = "../peg/patch.peg"]
pub struct PatchParser<'a> {
text: &'a [String],
patch: &'a str,
pub struct PatchParser {
text: Vec<String>,
patch: String,
}

#[derive(Default)]
Expand All @@ -34,13 +34,13 @@ impl fmt::Display for ContextHeader {
}
}

impl<'a> PatchParser<'a> {
pub fn new(text: &'a [String], patch: &'a str) -> Self {
impl PatchParser {
pub fn new(text: Vec<String>, patch: String) -> Self {
Self { text, patch }
}

pub fn process(&self) -> PatchResult<Vec<String>> {
let patch = Self::parse(Rule::patch, self.patch)?
let patch = Self::parse(Rule::patch, &self.patch)?
.next()
.ok_or(PatchErrorKind::NotFound("patch"))?;

Expand Down

0 comments on commit 9f31126

Please sign in to comment.