summaryrefslogtreecommitdiffstats
path: root/vendor/regex/src/re_unicode.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
commit17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch)
tree3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /vendor/regex/src/re_unicode.rs
parentAdding upstream version 1.64.0+dfsg1. (diff)
downloadrustc-17d40c6057c88f4c432b0d7bac88e1b84cb7e67f.tar.xz
rustc-17d40c6057c88f4c432b0d7bac88e1b84cb7e67f.zip
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/regex/src/re_unicode.rs')
-rw-r--r--vendor/regex/src/re_unicode.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/vendor/regex/src/re_unicode.rs b/vendor/regex/src/re_unicode.rs
index e4871a621..60d81a7d9 100644
--- a/vendor/regex/src/re_unicode.rs
+++ b/vendor/regex/src/re_unicode.rs
@@ -61,7 +61,7 @@ impl<'t> Match<'t> {
/// Creates a new match from the given haystack and byte offsets.
#[inline]
fn new(haystack: &'t str, start: usize, end: usize) -> Match<'t> {
- Match { text: haystack, start: start, end: end }
+ Match { text: haystack, start, end }
}
}
@@ -129,7 +129,7 @@ impl<'t> From<Match<'t>> for Range<usize> {
/// assert!(haystack.contains(&re));
/// assert_eq!(haystack.find(&re), Some(1));
/// assert_eq!(haystack.match_indices(&re).collect::<Vec<_>>(),
-/// vec![(1, 4), (5, 8)]);
+/// vec![(1, "111"), (5, "222")]);
/// assert_eq!(haystack.split(&re).collect::<Vec<_>>(), vec!["a", "b", "c"]);
/// ```
#[derive(Clone)]
@@ -311,7 +311,7 @@ impl Regex {
pub fn captures<'t>(&self, text: &'t str) -> Option<Captures<'t>> {
let mut locs = self.capture_locations();
self.captures_read_at(&mut locs, text, 0).map(move |_| Captures {
- text: text,
+ text,
locs: locs.0,
named_groups: self.0.capture_name_idx().clone(),
})
@@ -636,7 +636,7 @@ impl Regex {
/// context into consideration. For example, the `\A` anchor can only
/// match when `start == 0`.
pub fn is_match_at(&self, text: &str, start: usize) -> bool {
- self.shortest_match_at(text, start).is_some()
+ self.0.searcher_str().is_match_at(text, start)
}
/// Returns the same as find, but starts the search at the given
@@ -887,7 +887,7 @@ impl CaptureLocations {
self.0.pos(i)
}
- /// Returns the total number of capturing groups.
+ /// Returns the total number of capture groups (even if they didn't match).
///
/// This is always at least `1` since every regex has at least `1`
/// capturing group that corresponds to the entire match.
@@ -989,7 +989,7 @@ impl<'t> Captures<'t> {
expand_str(self, replacement, dst)
}
- /// Returns the number of captured groups.
+ /// Returns the total number of capture groups (even if they didn't match).
///
/// This is always at least `1`, since every regex has at least one capture
/// group that corresponds to the full match.
@@ -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<usize>) {
+ 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
@@ -1114,7 +1124,7 @@ impl<'r, 't> Iterator for CaptureMatches<'r, 't> {
fn next(&mut self) -> Option<Captures<'t>> {
self.0.next().map(|locs| Captures {
text: self.0.text(),
- locs: locs,
+ locs,
named_groups: self.0.regex().capture_name_idx().clone(),
})
}