diff --git a/src/re_trait.rs b/src/re_trait.rs index 680aa5459..7967e2944 100644 --- a/src/re_trait.rs +++ b/src/re_trait.rs @@ -74,8 +74,19 @@ impl<'c> Iterator for SubCapturesPosIter<'c> { self.idx += 1; x } + + fn size_hint(&self) -> (usize, Option) { + let len = self.locs.len() - self.idx; + (len, Some(len)) + } + + fn count(self) -> usize { + self.len() + } } +impl<'c> ExactSizeIterator for SubCapturesPosIter<'c> {} + impl<'c> FusedIterator for SubCapturesPosIter<'c> {} /// `RegularExpression` describes types that can implement regex searching. diff --git a/src/re_unicode.rs b/src/re_unicode.rs index 7c73dbc58..8c4ecfc9c 100644 --- a/src/re_unicode.rs +++ b/src/re_unicode.rs @@ -1092,8 +1092,18 @@ impl<'c, 't> Iterator for SubCaptureMatches<'c, 't> { .next() .map(|cap| cap.map(|(s, e)| Match::new(self.caps.text, s, e))) } + + fn size_hint(&self) -> (usize, Option) { + self.it.size_hint() + } + + fn count(self) -> usize { + self.it.count() + } } +impl<'c, 't> ExactSizeIterator for SubCaptureMatches<'c, 't> {} + impl<'c, 't> FusedIterator for SubCaptureMatches<'c, 't> {} /// An iterator that yields all non-overlapping capture groups matching a