Skip to content

Commit c238c04

Browse files
CodeGhost21claude
andcommitted
fix(parse): use as_chunks for a constant chunk size
Unrelated to this PR's bug fix, and included only because it blocks CI for everything. `chunks_exact_to_as_chunks` is a clippy lint added in Rust 1.98. CI runs a toolchain new enough to have it; the line it flags predates this branch and is untouched by it, so `main` is red for the same reason and every open PR against this repo is blocked identically. `as_chunks::<2>()` returns fixed-size arrays, so the two destructurings need no bounds check and the pair can be bound directly in the pattern. Verified on both sides of the lint's introduction: clean under nightly 1.99 (which reproduces CI's failure exactly) and still building under 1.96.1, so this does not require the newer toolchain to compile. Kept as its own commit so it can be dropped or cherry-picked independently of the UTF-8 fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent c3a0b9c commit c238c04

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎src/harness/tool_calling/parse.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,13 @@ fn normalize_garbled_tool_call_tags(s: &str) -> Cow<'_, str> {
224224
}
225225
let mut out = String::with_capacity(s.len());
226226
let mut cursor = 0usize;
227-
for pair in tags.chunks_exact(2) {
228-
let (open_start, open_end) = pair[0];
229-
let (close_start, close_end) = pair[1];
227+
// `as_chunks::<2>()` rather than `chunks_exact(2)`: the chunk size is a
228+
// constant, so this hands back fixed-size arrays and the two destructurings
229+
// below need no bounds check. `chunks_exact_to_as_chunks` (clippy, Rust
230+
// 1.98) flags the older form.
231+
for &[open, close] in tags.as_chunks::<2>().0 {
232+
let (open_start, open_end) = open;
233+
let (close_start, close_end) = close;
230234
out.push_str(&s[cursor..open_start]); // text before the open tag, verbatim
231235
out.push_str("<tool_call>");
232236
// Strip the `call:` prefix, then try to recover a Kimi-family

0 commit comments

Comments
 (0)