From 9d1885b245159ca22cbe79da7b7f5a6a3d02f7c8 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 23 Sep 2022 22:37:17 +0300 Subject: [PATCH] trim instead of replace --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index de0f42c..54db8f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -204,7 +204,7 @@ impl QuestionsParser { self.last_keyword_type = self.cur_keyword_type; self.last_tag = self.cur_tag.clone(); self.cur_keyword_type = Some(keyword.parse().unwrap()); - self.cur_tag = keyword.replace(' ', "").replace(':', ""); + self.cur_tag = keyword.trim_end().trim_end_matches(':').to_string(); } /// if line matched keyword fn on_keyword_match(&mut self, line: &str, keyword: &str) { @@ -212,7 +212,7 @@ impl QuestionsParser { // remember question id if let Some(KeywordType::QuestionStart) = self.cur_keyword_type { - self.cur_question_pre["id"] = line.replace(':', "").into(); + self.cur_question_pre["id"] = line.trim_end().trim_end_matches(':').into(); }; self.apply_content_for_last_keyword();