diff --git a/src/regexset/bytes.rs b/src/regexset/bytes.rs index 2f46abc4d..46f02fbbd 100644 --- a/src/regexset/bytes.rs +++ b/src/regexset/bytes.rs @@ -482,6 +482,24 @@ impl SetMatches { !self.0.is_empty() } + /// Whether all patterns in this set matched. + /// + /// # Example + /// + /// ``` + /// use regex::bytes::RegexSet; + /// + /// let set = RegexSet::new(&[ + /// r"^foo", + /// r"[a-z]+\.com", + /// ]).unwrap(); + /// let matches = set.matches(b"foo.example.com"); + /// assert!(matches.matched_all()); + /// ``` + pub fn matched_all(&self) -> bool { + self.0.is_full() + } + /// Whether the regex at the given index matched. /// /// The index for a regex is determined by its insertion order upon the diff --git a/src/regexset/string.rs b/src/regexset/string.rs index 5cb9b5608..535a670c8 100644 --- a/src/regexset/string.rs +++ b/src/regexset/string.rs @@ -478,6 +478,24 @@ impl SetMatches { !self.0.is_empty() } + /// Whether all patterns in this set matched. + /// + /// # Example + /// + /// ``` + /// use regex::RegexSet; + /// + /// let set = RegexSet::new(&[ + /// r"^foo", + /// r"[a-z]+\.com", + /// ]).unwrap(); + /// let matches = set.matches("foo.example.com"); + /// assert!(matches.matched_all()); + /// ``` + pub fn matched_all(&self) -> bool { + self.0.is_full() + } + /// Whether the regex at the given index matched. /// /// The index for a regex is determined by its insertion order upon the