Skip to main content

Module chars_util

Module chars_util 

Source
Expand description

Character helpers shared by the structural matchers. The reference walks Python strings by code point; these helpers provide the same semantics over Rust byte offsets.

Functions§

char_at
The character starting at (or spanning) byte_idx, if the index is a char boundary.
char_before
The character ending just before byte_idx, if byte_idx is a boundary.
py_is_word
Python \w membership (Unicode word character or underscore).
str_find_from
Python str.find(sub, start, end).
str_rfind_in
Python str.rfind(sub, start, end): last occurrence within [start, end).
walk_back_while
Walk to the start of the run of pred characters ending at byte_idx (exclusive), like the reference’s backward while loops.
walk_forward_while
Walk forward from byte_idx over pred characters, returning the end.