use mem::replace in add_cur_question
This commit is contained in:
parent
aed59f4663
commit
24f675ca16
@ -137,7 +137,8 @@ impl QuestionsParser {
|
||||
/// add current question to parsed array
|
||||
fn add_cur_question(&mut self) {
|
||||
if self.is_current_question_valid() {
|
||||
self.questions.push(self.cur_question.clone()).unwrap_or(())
|
||||
let current = std::mem::replace(&mut self.cur_question, self.cur_question_pre.clone());
|
||||
self.questions.push(current).unwrap()
|
||||
}
|
||||
}
|
||||
/// set current content to last tag(keyword) to data scope
|
||||
@ -171,8 +172,6 @@ impl QuestionsParser {
|
||||
if self.have_new_question {
|
||||
self.add_cur_question();
|
||||
}
|
||||
// prepare to read new question data with cur_question_pre values
|
||||
self.cur_question = self.cur_question_pre.clone();
|
||||
self.have_new_question = true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user