summaryrefslogtreecommitdiffstats
path: root/vendor/regex/src/re_bytes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/regex/src/re_bytes.rs')
-rw-r--r--vendor/regex/src/re_bytes.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/vendor/regex/src/re_bytes.rs b/vendor/regex/src/re_bytes.rs
index d71969257..07e9f98ac 100644
--- a/vendor/regex/src/re_bytes.rs
+++ b/vendor/regex/src/re_bytes.rs
@@ -496,12 +496,12 @@ impl Regex {
let mut new = Vec::with_capacity(text.len());
let mut last_match = 0;
for (i, m) in it {
- if limit > 0 && i >= limit {
- break;
- }
new.extend_from_slice(&text[last_match..m.start()]);
new.extend_from_slice(&rep);
last_match = m.end();
+ if limit > 0 && i >= limit - 1 {
+ break;
+ }
}
new.extend_from_slice(&text[last_match..]);
return Cow::Owned(new);
@@ -516,14 +516,14 @@ impl Regex {
let mut new = Vec::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.extend_from_slice(&text[last_match..m.start()]);
rep.replace_append(&cap, &mut new);
last_match = m.end();
+ if limit > 0 && i >= limit - 1 {
+ break;
+ }
}
new.extend_from_slice(&text[last_match..]);
Cow::Owned(new)