summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/lib.rs2
-rw-r--r--src/regex_set.rs8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1ee24187..79385dc1 100755
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -56,7 +56,7 @@ mod clangll;
doc_mod!(clang);
doc_mod!(ir);
doc_mod!(parse);
-mod regex_set;
+doc_mod!(regex_set);
mod codegen {
include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
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>
{