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:19:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
commit2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 (patch)
treed325add32978dbdc1db975a438b3a77d571b1ab8 /vendor/regex/src/re_unicode.rs
parentReleasing progress-linux version 1.68.2+dfsg1-1~progress7.99u1. (diff)
downloadrustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.tar.xz
rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.zip
Merging upstream version 1.69.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.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/vendor/regex/src/re_unicode.rs b/vendor/regex/src/re_unicode.rs
index 60d81a7d9..197510ea0 100644
--- a/vendor/regex/src/re_unicode.rs
+++ b/vendor/regex/src/re_unicode.rs
@@ -554,12 +554,12 @@ impl Regex {
let mut new = String::with_capacity(text.len());
let mut last_match = 0;
for (i, m) in it {
- if limit > 0 && i >= limit {
- break;
- }
new.push_str(&text[last_match..m.start()]);
new.push_str(&rep);
last_match = m.end();
+ if limit > 0 && i >= limit - 1 {
+ break;
+ }
}
new.push_str(&text[last_match..]);
return Cow::Owned(new);
@@ -574,14 +574,14 @@ impl Regex {
let mut new = String::with_capacity(text.len());
let mut last_match = 0;
for (i, cap) in it {
- if limit > 0 && i >= limit {
- break;
- }
// unwrap on 0 is OK because captures only reports matches
let m = cap.get(0).unwrap();
new.push_str(&text[last_match..m.start()]);
rep.replace_append(&cap, &mut new);
last_match = m.end();
+ if limit > 0 && i >= limit - 1 {
+ break;
+ }
}
new.push_str(&text[last_match..]);
Cow::Owned(new)