Skip to content

Commit bf63fe8

Browse files
authored
regex: add as_match method to Captures trait
Ref rust-lang/regex#1146 PR #2898
1 parent 8bd5950 commit bf63fe8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/matcher/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,15 @@ pub trait Captures {
389389
/// for the overall match.
390390
fn get(&self, i: usize) -> Option<Match>;
391391

392+
/// Return the overall match for the capture.
393+
///
394+
/// This returns the match for index `0`. That is it is equivalent to
395+
/// `get(0).unwrap()`
396+
#[inline]
397+
fn as_match(&self) -> Match {
398+
self.get(0).unwrap()
399+
}
400+
392401
/// Returns true if and only if these captures are empty. This occurs
393402
/// when `len` is `0`.
394403
///

0 commit comments

Comments
 (0)