fix: matchAll 迭代器 next 按规范重写为 RegExpExec 协议与内部槽语义

This commit is contained in:
2026-09-26 14:35:21 +00:00
parent 381eebb02d
commit d773cc7282
5 changed files with 213 additions and 119 deletions
@@ -174,16 +174,6 @@ fn clamp_code_point_start(u: &[u16], idx: usize) -> usize {
}
}
/// 给定码元位置之后的下一个码点边界(空匹配游标推进用):跳过低 surrogate
/// 位到下一码点起点;位置在串尾时返回串长+1(触发耗尽守卫)。
pub(crate) fn next_code_point_boundary(u: &[u16], idx: usize) -> usize {
let mut j = idx + 1;
while j < u.len() && is_low_surrogate(u[j]) && is_high_surrogate(u[j - 1]) {
j += 1;
}
j
}
#[inline]
fn is_low_surrogate(u: u16) -> bool {
(0xDC00..=0xDFFF).contains(&u)