Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: add SetMatches::matched_all #1228

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/regexset/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,24 @@ impl SetMatches {
!self.0.is_empty()
}

/// Whether all patterns in this set matched
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you missed a period here (and below).

///
/// # 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
Expand Down
18 changes: 18 additions & 0 deletions src/regexset/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down