strings: preserve UTF-8 and boundary invariants

This commit is contained in:
2026-08-09 17:46:22 +09:00
parent 2d947c469e
commit 8e2e6ae162
7 changed files with 124 additions and 61 deletions

View File

@@ -40,9 +40,9 @@ Signatures mirror Hare too, modulo:
- `(T | U)` sum-typed parameters dispatch via `match` inside the
callee. `strings.byteindex(haystack: str, needle: (str | rune))`,
`bytes.index(s: []u8, needle: (u8 | []u8))`, and `rbyteindex`/
`rindex` follow Hare's shape directly. The rune-indexed
`strings.index` (rune-wise position) isn't shipped yet — we don't
have UTF-8 rune iteration in the language stack.
`rindex` follow Hare's shape directly. `strings.index`/`rindex` expose
rune positions; `byteindex`/`rbyteindex` expose byte offsets. UTF-8
iterators and both indexing axes are shipped and tested.
Don't ship a richer surface than Hare has. A documented subset is
fine; an extension, rename, or convenience-wrapper is not — callers