summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-10-29 13:32:05 -0500
committerGitHub <noreply@github.com>2016-10-29 13:32:05 -0500
commitf99d129b5f676fee0cbd2771e77ce34f82629ebe (patch)
treeb41c677fc779aceca0c1adde4410ad8c470519be
parent3618f55f8067b11da15b0cc6650c229ffef3d170 (diff)
parent735fb48b50068e608d814c36e4cbad70e1b29849 (diff)
Auto merge of #157 - fitzgen:doc-regex-set-mod, r=emilio
Document the `regex_set` module r? @emilio
-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>
{