Skip to content

Add eq_ignore_ascii_case for char and String#760

Merged
gfx merged 6 commits intomainfrom
claude/add-char-eq-ignore-ascii-case-xkM5z
Apr 2, 2026
Merged

Add eq_ignore_ascii_case for char and String#760
gfx merged 6 commits intomainfrom
claude/add-char-eq-ignore-ascii-case-xkM5z

Conversation

@gfx
Copy link
Copy Markdown
Member

@gfx gfx commented Apr 2, 2026

Summary

  • Add char::eq_ignore_ascii_case(&self, other: &char) -> bool — delegates to to_ascii_lowercase comparison, matching Rust's implementation
  • Add String::eq_ignore_ascii_case(&self, other: String) -> bool — byte-level comparison using per-byte to_ascii_lowercase, matching Rust's str::eq_ignore_ascii_case
  • Make char::to_ascii_lowercase and char::to_ascii_uppercase branchless, matching Rust's u8 implementation pattern: c | (is_upper as u32 * ('A' ^ 'a'))

Test plan

  • primitive_test.wado: 5 test cases for char::eq_ignore_ascii_case (same case, different case, non-alpha, different letters, non-alpha with same bit pattern)
  • string_test.wado: 6 test cases for String::eq_ignore_ascii_case (same case, different case, non-alpha, different lengths, empty, non-ASCII)
  • All existing char and string tests pass across all optimization levels

https://claude.ai/code/session_01YTKHy6Dzb84sH6hyxVEDXz

claude added 5 commits April 2, 2026 22:24
Branchless ASCII case-insensitive comparison using the (x | 0x20)
lowering trick with unsigned underflow for range check.

https://claude.ai/code/session_01YTKHy6Dzb84sH6hyxVEDXz
Delegate to to_ascii_lowercase() instead of inline bit manipulation,
matching Rust stdlib's char::eq_ignore_ascii_case exactly.

https://claude.ai/code/session_01YTKHy6Dzb84sH6hyxVEDXz
Match Rust's u8 implementation pattern:
- to_ascii_lowercase: c | (is_upper as u32 * CASE_MASK)
- to_ascii_uppercase: c ^ (is_lower as u32 * CASE_MASK)

where CASE_MASK = 'A' ^ 'a' (0x20).

https://claude.ai/code/session_01YTKHy6Dzb84sH6hyxVEDXz
Byte-level comparison using per-byte to_ascii_lowercase, matching
Rust's str::eq_ignore_ascii_case which delegates to [u8]'s impl.

https://claude.ai/code/session_01YTKHy6Dzb84sH6hyxVEDXz
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Working tree is dirty

Integrity checks produced the following changes:

 docs/cheatsheet-stdlib-core.md                     |   2 +
 docs/stdlib-core.md                                |  12 ++
 .../fixtures.golden/iterator_trait_map.wir.wado    | 106 +++++++++--------
 .../fixtures.golden/string-truncate-panic.wir.wado |   4 +-
 .../tests/format.fixtures.golden/all.lower.wado    | 130 +++++++++++++--------
 .../tests/format.fixtures.golden/mess.lower.wado   | 130 +++++++++++++--------
 .../format.fixtures.golden/ops.all.lower.wado      | 130 +++++++++++++--------
 .../format.fixtures.golden/ops.mess.lower.wado     | 130 +++++++++++++--------
 8 files changed, 394 insertions(+), 250 deletions(-)

Please run mise run on-task-done locally and commit the changes.

@gfx gfx enabled auto-merge April 2, 2026 23:32
@gfx gfx merged commit 5147fb7 into main Apr 2, 2026
10 checks passed
@gfx gfx deleted the claude/add-char-eq-ignore-ascii-case-xkM5z branch April 2, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants