diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2016-10-27 16:28:45 -0700 |
---|---|---|
committer | Nick Fitzgerald <fitzgen@gmail.com> | 2016-10-27 16:28:45 -0700 |
commit | 735fb48b50068e608d814c36e4cbad70e1b29849 (patch) | |
tree | b8a6c17f906da6f5d6b7bdc909a4d9accfdd67aa /src/regex_set.rs | |
parent | 7130fb30f3eb37afa9d9397ae4d3f9432024e9b7 (diff) |
Document the `regex_set` module
Diffstat (limited to 'src/regex_set.rs')
-rw-r--r-- | src/regex_set.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/regex_set.rs b/src/regex_set.rs index 20bc56bf..ff899d78 100644 --- a/src/regex_set.rs +++ b/src/regex_set.rs @@ -1,18 +1,24 @@ +//! A type that represents the union of a set of regular expressions. + use std::borrow::Borrow; use regex::Regex; // Yeah, I'm aware this is sorta crappy, should be cheaper to compile a regex // ORing all the patterns, I guess... + +/// A dynamic set of regular expressions. #[derive(Debug)] pub struct RegexSet { items: Vec<Regex> } impl RegexSet { + /// Is this set empty? pub fn is_empty(&self) -> bool { self.items.is_empty() } + /// Extend this set with every regex in the iterator. pub fn extend<I>(&mut self, iter: I) where I: IntoIterator<Item=String> { @@ -21,6 +27,7 @@ impl RegexSet { } } + /// Insert a new regex into this set. pub fn insert<S>(&mut self, string: &S) where S: Borrow<str> { @@ -35,6 +42,7 @@ impl RegexSet { } } + /// Does the given `string` match any of the regexes in this set? pub fn matches<S>(&self, string: &S) -> bool where S: Borrow<str> { |