From 0a6bf7e2fc53a4f99e63b64f3f45dd899d76dd53 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Thu, 19 Sep 2024 00:17:36 -0600 Subject: [PATCH] regex: add as_match method to Captures Fixes: #1146 --- crates/matcher/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/matcher/src/lib.rs b/crates/matcher/src/lib.rs index 40cbff5d9..25afb0666 100644 --- a/crates/matcher/src/lib.rs +++ b/crates/matcher/src/lib.rs @@ -389,6 +389,15 @@ pub trait Captures { /// for the overall match. fn get(&self, i: usize) -> Option; + /// Return the overall match for the capture. + /// + /// This returns the match for index `0`. That is it is equivalent to + /// `get(0).unwrap()` + #[inline] + fn as_match(&self) -> Match { + self.get(0).unwrap() + } + /// Returns true if and only if these captures are empty. This occurs /// when `len` is `0`. ///