remove debug break + clippy
This commit is contained in:
parent
b4de387798
commit
390097b5b8
16
src/main.rs
16
src/main.rs
@ -115,13 +115,13 @@ fn parse_file(file: impl io::Read) -> Result<json::JsonValue, Box<std::error::Er
|
|||||||
// ignore empty lines
|
// ignore empty lines
|
||||||
let line_str = String::from(line.unwrap().trim());
|
let line_str = String::from(line.unwrap().trim());
|
||||||
let line_s = &line_str;
|
let line_s = &line_str;
|
||||||
if 0 == line_s.len() {
|
if line_s.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// find keywords
|
// find keywords
|
||||||
match patterns
|
match patterns
|
||||||
.iter()
|
.iter()
|
||||||
.find(|&&pattern| line_s.starts_with(pattern) && line_s.ends_with(":"))
|
.find(|&&pattern| line_s.starts_with(pattern) && line_s.ends_with(':'))
|
||||||
{
|
{
|
||||||
Some(pattern) => {
|
Some(pattern) => {
|
||||||
use KeywordType::*;
|
use KeywordType::*;
|
||||||
@ -129,14 +129,11 @@ fn parse_file(file: impl io::Read) -> Result<json::JsonValue, Box<std::error::Er
|
|||||||
ctx.last_keyword_type = ctx.cur_keyword_type;
|
ctx.last_keyword_type = ctx.cur_keyword_type;
|
||||||
ctx.last_tag = ctx.cur_tag.clone();
|
ctx.last_tag = ctx.cur_tag.clone();
|
||||||
ctx.cur_keyword_type = Some(keyword_type(&pattern));
|
ctx.cur_keyword_type = Some(keyword_type(&pattern));
|
||||||
ctx.cur_tag = pattern.replace(" ", "").replace(":", "");
|
ctx.cur_tag = pattern.replace(' ', "").replace(':', "");
|
||||||
|
|
||||||
// remember question id
|
// remember question id
|
||||||
match ctx.cur_keyword_type {
|
if let Some(QuestionStart) = ctx.cur_keyword_type {
|
||||||
Some(QuestionStart) => {
|
ctx.cur_question_pre["id"] = line_s.replace(':', "").as_str().into();
|
||||||
ctx.cur_question_pre["id"] = line_s.replace(":", "").as_str().into();
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// apply accumulated content when new keyword found
|
// apply accumulated content when new keyword found
|
||||||
@ -222,9 +219,6 @@ fn main() -> Result<(), Box<std::error::Error>> {
|
|||||||
let mut outfile = fs::File::create(outfilename)?;
|
let mut outfile = fs::File::create(outfilename)?;
|
||||||
|
|
||||||
data.write_pretty(&mut outfile, 1)?;
|
data.write_pretty(&mut outfile, 1)?;
|
||||||
//data.write(&mut outfile)?;
|
|
||||||
//debug
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user