summaryrefslogtreecommitdiff
path: root/src/regex_set.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/regex_set.rs')
-rw-r--r--src/regex_set.rs8
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>
{