diff options
Diffstat (limited to 'regex_set.rs')
-rw-r--r-- | regex_set.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/regex_set.rs b/regex_set.rs index 1d5cad2..b78424a 100644 --- a/regex_set.rs +++ b/regex_set.rs @@ -7,7 +7,7 @@ use std::cell::Cell; /// A dynamic set of regular expressions. #[derive(Clone, Debug, Default)] pub struct RegexSet { - items: Vec<String>, + items: Vec<Box<str>>, /// Whether any of the items in the set was ever matched. The length of this /// vector is exactly the length of `items`. matched: Vec<Cell<bool>>, @@ -32,25 +32,25 @@ impl RegexSet { where S: AsRef<str>, { - self.items.push(string.as_ref().to_owned()); + self.items.push(string.as_ref().to_owned().into_boxed_str()); self.matched.push(Cell::new(false)); self.set = None; } /// Returns slice of String from its field 'items' - pub fn get_items(&self) -> &[String] { - &self.items[..] + pub fn get_items(&self) -> &[Box<str>] { + &self.items } /// Returns an iterator over regexes in the set which didn't match any /// strings yet. - pub fn unmatched_items(&self) -> impl Iterator<Item = &String> { + pub fn unmatched_items(&self) -> impl Iterator<Item = &str> { self.items.iter().enumerate().filter_map(move |(i, item)| { if !self.record_matches || self.matched[i].get() { return None; } - Some(item) + Some(item.as_ref()) }) } @@ -197,7 +197,7 @@ fn invalid_regex_warning( Level::Note, ); - if set.items.iter().any(|item| item == "*") { + if set.items.iter().any(|item| item.as_ref() == "*") { diagnostic.add_annotation("Wildcard patterns \"*\" are no longer considered valid. Use \".*\" instead.", Level::Help); } diagnostic.display(); |