use mem::replace in add_cur_question

This commit is contained in:
Dmitry Belyaev 2022-09-23 23:20:17 +03:00
parent aed59f4663
commit 24f675ca16
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
1 changed files with 2 additions and 3 deletions

View File

@ -137,7 +137,8 @@ impl QuestionsParser {
/// add current question to parsed array /// add current question to parsed array
fn add_cur_question(&mut self) { fn add_cur_question(&mut self) {
if self.is_current_question_valid() { 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 /// set current content to last tag(keyword) to data scope
@ -171,8 +172,6 @@ impl QuestionsParser {
if self.have_new_question { if self.have_new_question {
self.add_cur_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; self.have_new_question = true;
} }