Repository navigation
feat(ts): translate str::chars, char patterns, and String::push - #96
Conversation
Quest-Claim: 93dc02fbf02063bc
`str::chars`, `split`, `match_indices`, `starts_with`, `trim_start_matches`, `trim_end_matches`, and `rfind` by a `char` or a predicate, `str::is_empty`, `char::is_ascii_digit`, and `String::push` through a `&mut String` translate, so moq-net's `ietf/namespace.rs` refuses only its `Cow`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 464c9f1
No actionable bugs found in the changed areas. The shared two-ended searcher is justified over eager splitting: it preserves lazy predicate evaluation and mixed-direction iteration. UTF-8 offset accounting remains separate from UTF-16 traversal, and String::push reuses the existing borrowed-place restrictions rather than pretending JavaScript strings are mutable references. Keeping &str patterns and arbitrary &mut String parameters explicitly unsupported is a reasonable scope boundary.
Reviewed runtime searches, translator mappings/assignment handling, generated snapshots, and differential/refusal fixtures. The Unicode-boundary and predicate-order cases are meaningful coverage. Source review only; I did not run the translator, native/wasm differential tests, or the full suite.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Give #96's strs and this branch's stores their own ops (% 44), and regenerate the harness snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Keep both sides' reject cases (copy_within and Arc<[u8]> beside #96's String and str patterns), and regenerate the snapshots over #96's and #99's lowering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
* chore(quest): default comparison methods and generic instances Follow-ups from #98 and #94. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * chore(quest): Cow<str> and str slicing from #96 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * chore(quest): share Copy types the crate never changes in place Replaces ts-shared-read's narrow fix, as #99 suggested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * chore(quest): an A/A control that measures noise From #87's and #97's bench findings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn --------- Co-authored-by: Luke Curley <432854+kixelated@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
#86 made
charvalues translate, but thestrandStringmethods over them did not: moq-net'sietf/namespace.rsrefusedstr::chars,split('/'),is_empty, and eightString::pushcalls, and other modules refused the remainingchar-pattern searches andchar::is_ascii_digit.Approach
rt/str.ts(new):strChars, a double-ended iterator stepping by code point, and the searchesstrSplit,strMatchIndices,strStartsWith,strTrimStartMatches,strTrimEndMatches, andstrRfind. Each takes anrt.Pattern: the char's text, whichindexOffinds, or the predicate itself. The searcher is a port of std's: it keeps a front and a back finger, so mixingnextandnext_backmatches std, and it calls a predicate once per char it reads, in std's order.rfindandmatch_indicesreturn UTF-8 byte offsets, counted from the code units (a surrogate pair counts as 4 bytes).match_indiceskeeps a running count from each end, so it stays linear.library.rs: maps those methods, plusstr::is_empty,String::is_empty, andchar::is_ascii_digit. Any pattern other than achar, a closure, or a fn item stays an unsupported call.mir/call.rs:String::pushassignsplace + textto whatever the&mutborrows: a local, a field (also through&mut self), or an element. A constant char becomes a string literal. A&mut Stringparameter is still refused, as other&mutto values JS copies are.langfixture gets astrscase, checked against native and wasm32 builds. Its text uses chars of each UTF-8 width and the ones on either side of the surrogate range and of U+FFFF/U+10000. It mixesnextandnext_back, logs every char a predicate is called with, and includes namespace.rs's escape/unescape loop. To check the tests catch bugs, I brokeutf8Lenand, separately, the surrogate stepping inbefore; the differential failed both times.rejectpins the refusals for a&strpattern and for a push through a parameter.moq-net census at the pinned moq rev, measured on main at 62a8a59:
ietf/namespace.rsAfter merging #87, moq-net has 11503 refusals and kio 344 (#87's drops);
namespace.rsstill has 1. This PR does not change kio (355 before and after on 62a8a59).namespace.rsstill refuses<Cow<str> as From<&str>>::frominrefusal. That comes fromCow, not fromstrorchar, so I did not fix it here.Impact
rt/str.ts, re-exported fromrt.ts, exportingPattern,strChars,strSplit,strMatchIndices,strStartsWith,strTrimStartMatches,strTrimEndMatches, andstrRfind.rt.tsalso gainscharIsAsciiDigit.Alternatives
s.split(c)into an array: rejected. It is not lazy, it can't run a predicate in std's order, and it does extra work forsplit(..).next().string | predicate: rejected. That doubles the API to save onetypeofcheck per call.&strpatterns (starts_with::<&str>andcontains::<&str>inpath/mod.rs): left out of scope. An empty&strpattern has its own semantics insplit,trim_*, andmatch_indices.Follow-ups
Cow<str>: 139 moq-net refusals, including the last one innamespace.rs.&strpatterns, andstrslicing by byte range (&s[..i]). Slicing is what makes the byte offsets fromrfindandmatch_indicesuseful indiscovery.rsandlite/compress.rs.(written by Opus 5.5)
🤖 Generated with Claude Code
https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn