diff --git a/src/re_bytes.rs b/src/re_bytes.rs
index 0e3fc777b7..e42ae30437 100644
--- a/src/re_bytes.rs
+++ b/src/re_bytes.rs
@@ -682,21 +682,21 @@ impl<'t> Captures<'t> {
/// Creates an iterator of all the capture groups in order of appearance
/// in the regular expression.
- pub fn iter<'a>(&'a self) -> SubCaptures<'a, 't> {
+ pub fn iter<'c>(&'c self) -> SubCaptures<'c, 't> {
SubCaptures { idx: 0, caps: self }
}
/// Creates an iterator of all the capture group positions in order of
/// appearance in the regular expression. Positions are byte indices
/// in terms of the original string matched.
- pub fn iter_pos(&'t self) -> SubCapturesPos<'t> {
+ pub fn iter_pos<'c>(&'c self) -> SubCapturesPos<'c> {
SubCapturesPos { idx: 0, slots: &self.slots }
}
/// Creates an iterator of all named groups as an tuple with the group
/// name and the value. The iterator returns these values in arbitrary
/// order.
- pub fn iter_named<'a>(&'a self) -> SubCapturesNamed<'a, 't> {
+ pub fn iter_named<'c>(&'c self) -> SubCapturesNamed<'c, 't> {
SubCapturesNamed {
caps: self,
names: self.named_groups.iter()
diff --git a/src/re_unicode.rs b/src/re_unicode.rs
index 4653ee3430..8f671633b3 100644
--- a/src/re_unicode.rs
+++ b/src/re_unicode.rs
@@ -874,21 +874,21 @@ impl<'t> Captures<'t> {
/// Creates an iterator of all the capture groups in order of appearance
/// in the regular expression.
- pub fn iter(&'t self) -> SubCaptures<'t> {
+ pub fn iter<'c>(&'c self) -> SubCaptures<'c, 't> {
SubCaptures { idx: 0, caps: self, }
}
/// Creates an iterator of all the capture group positions in order of
/// appearance in the regular expression. Positions are byte indices
/// in terms of the original string matched.
- pub fn iter_pos(&'t self) -> SubCapturesPos<'t> {
+ pub fn iter_pos<'c>(&'c self) -> SubCapturesPos<'c> {
SubCapturesPos { idx: 0, slots: &self.slots }
}
/// Creates an iterator of all named groups as an tuple with the group
/// name and the value. The iterator returns these values in arbitrary
/// order.
- pub fn iter_named(&'t self) -> SubCapturesNamed<'t> {
+ pub fn iter_named<'c>(&'c self) -> SubCapturesNamed<'c, 't> {
SubCapturesNamed {
caps: self,
names: self.named_groups.iter()
@@ -1013,16 +1013,17 @@ impl<'t, 'i> Index<&'i str> for Captures<'t> {
/// An iterator over capture groups for a particular match of a regular
/// expression.
///
-/// `'c` is the lifetime of the captures.
-pub struct SubCaptures<'c> {
+/// `'c` is the lifetime of the captures and `'t` is the lifetime of the
+/// matched text.
+pub struct SubCaptures<'c, 't: 'c> {
idx: usize,
- caps: &'c Captures<'c>,
+ caps: &'c Captures<'t>,
}
-impl<'c> Iterator for SubCaptures<'c> {
- type Item = Option<&'c str>;
+impl<'c, 't> Iterator for SubCaptures<'c, 't> {
+ type Item = Option<&'t str>;
- fn next(&mut self) -> Option