Move divide_text() into scope of impl Parser
This commit is contained in:
parent
b6d52b2616
commit
d54825de6b
1 changed files with 17 additions and 16 deletions
|
@ -109,7 +109,7 @@ impl<HP, DP> Parser<HP, DP> where
|
||||||
where FD: FileData + Sized,
|
where FD: FileData + Sized,
|
||||||
DP: FileDataParser<FD>
|
DP: FileDataParser<FD>
|
||||||
{
|
{
|
||||||
let divided = divide_text(&s);
|
let divided = self.divide_text(&s);
|
||||||
|
|
||||||
if divided.is_err() {
|
if divided.is_err() {
|
||||||
return Err(divided.err().unwrap());
|
return Err(divided.err().unwrap());
|
||||||
|
@ -149,9 +149,8 @@ impl<HP, DP> Parser<HP, DP> where
|
||||||
|
|
||||||
Ok(h_text.ok().unwrap() + &d_text.ok().unwrap()[..])
|
Ok(h_text.ok().unwrap() + &d_text.ok().unwrap()[..])
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn divide_text(text: &String) -> Result<TextTpl, ParserError> {
|
fn divide_text(&self, text: &String) -> Result<TextTpl, ParserError> {
|
||||||
let re = Regex::new(r"(?m)^\-\-\-$\n(.*)^\-\-\-$\n(.*)").unwrap();
|
let re = Regex::new(r"(?m)^\-\-\-$\n(.*)^\-\-\-$\n(.*)").unwrap();
|
||||||
|
|
||||||
let captures = re.captures(&text[..]).unwrap_or(
|
let captures = re.captures(&text[..]).unwrap_or(
|
||||||
|
@ -169,5 +168,7 @@ fn divide_text(text: &String) -> Result<TextTpl, ParserError> {
|
||||||
let header = captures.at(0).map(|s| String::from(s));
|
let header = captures.at(0).map(|s| String::from(s));
|
||||||
let content = captures.at(1).map(|s| String::from(s));
|
let content = captures.at(1).map(|s| String::from(s));
|
||||||
Ok((header, content))
|
Ok((header, content))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue