diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-10-29 13:32:05 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-29 13:32:05 -0500 |
commit | f99d129b5f676fee0cbd2771e77ce34f82629ebe (patch) | |
tree | b41c677fc779aceca0c1adde4410ad8c470519be | |
parent | 3618f55f8067b11da15b0cc6650c229ffef3d170 (diff) | |
parent | 735fb48b50068e608d814c36e4cbad70e1b29849 (diff) |
Auto merge of #157 - fitzgen:doc-regex-set-mod, r=emilio
Document the `regex_set` module
r? @emilio
-rwxr-xr-x | src/lib.rs | 2 | ||||
-rw-r--r-- | src/regex_set.rs | 8 |
2 files changed, 9 insertions, 1 deletions
@@ -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> { |