Skip to content

Commit 764efbd

Browse files
committed
api: tweak the lifetime of Captures::get_match
This was incredibly subtle and easy to miss. I actually didn't see any warnings for this until I did `cargo publish` for the `1.12.0` release. Not sure why. I'll have to yank the `1.12.0` release because this is technically a breaking change from the API published in `1.12.0`. Sigh. In particular, in `1.12.0`, I assumed the inferred lifetime is tied to the borrow of `Captures`, which is less than or equal to the lifetime of the haystack `'h`.
1 parent ee6aa55 commit 764efbd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/regex/bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ impl<'h> Captures<'h> {
16811681
/// assert_eq!(caps.get_match().as_bytes(), b"abc123");
16821682
/// ```
16831683
#[inline]
1684-
pub fn get_match(&self) -> Match {
1684+
pub fn get_match(&self) -> Match<'h> {
16851685
self.get(0).unwrap()
16861686
}
16871687

src/regex/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ impl<'h> Captures<'h> {
16921692
///
16931693
/// ```
16941694
#[inline]
1695-
pub fn get_match(&self) -> Match {
1695+
pub fn get_match(&self) -> Match<'h> {
16961696
self.get(0).unwrap()
16971697
}
16981698

0 commit comments

Comments
 (0)