diff options
author | Seo Sanghyeon <sanxiyn@gmail.com> | 2018-12-19 23:38:14 +0900 |
---|---|---|
committer | Seo Sanghyeon <sanxiyn@gmail.com> | 2018-12-19 23:38:14 +0900 |
commit | 7b3038e8bdf5435d2dd56ce2115f06966f59b225 (patch) | |
tree | e4c52730c394552cf17dda16e31d453348d7842e /src/regex_set.rs | |
parent | 371e744e4158f23e75adb296433fc684076964ad (diff) |
Store original strings in RegexSet
Diffstat (limited to 'src/regex_set.rs')
-rw-r--r-- | src/regex_set.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/regex_set.rs b/src/regex_set.rs index ce8714d4..6e2ca662 100644 --- a/src/regex_set.rs +++ b/src/regex_set.rs @@ -20,7 +20,7 @@ impl RegexSet { where S: AsRef<str>, { - self.items.push(format!("^{}$", string.as_ref())); + self.items.push(string.as_ref().to_owned()); self.set = None; } @@ -34,7 +34,8 @@ impl RegexSet { /// Must be called before calling `matches()`, or it will always return /// false. pub fn build(&mut self) { - self.set = match RxSet::new(&self.items) { + let items = self.items.iter().map(|item| format!("^{}$", item)); + self.set = match RxSet::new(items) { Ok(x) => Some(x), Err(e) => { error!("Invalid regex in {:?}: {:?}", self.items, e); |