Skip to content
Open
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
9 changes: 9 additions & 0 deletions src/regex/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,15 @@ impl<'h> Captures<'h> {
.map(|sp| Match::new(self.haystack, sp.start, sp.end))
}

/// Return the overall match for the capture.
Copy link
Member

Choose a reason for hiding this comment

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

Please add an example. I try to include an example for every public API item.

///
/// This returns the match for index `0`. That is it is equivalent to
/// `get(0).unwrap()`
Copy link
Member

Choose a reason for hiding this comment

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

Can you use m.get(0).unwrap()?

#[inline]
pub fn as_match(&self) -> Match {
self.get(0).unwrap()
}

/// Returns the `Match` associated with the capture group named `name`. If
/// `name` isn't a valid capture group or it refers to a group that didn't
/// match, then `None` is returned.
Expand Down
9 changes: 9 additions & 0 deletions src/regex/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,15 @@ impl<'h> Captures<'h> {
.map(|sp| Match::new(self.haystack, sp.start, sp.end))
}

/// Return the overall match for the capture.
///
/// This returns the match for index `0`. That is it is equivalent to
/// `get(0).unwrap()`
#[inline]
pub fn as_match(&self) -> Match {
self.get(0).unwrap()
}

/// Returns the `Match` associated with the capture group named `name`. If
/// `name` isn't a valid capture group or it refers to a group that didn't
/// match, then `None` is returned.
Expand Down