Just a small remark regarding terminology: What you likely meant is a Unicode Code Point or Unicode Scalar Value (opposed to a Grapheme Cluster or EGC). But maybe I misunderstood something?
Grapheme clusters might not fit into a 32 bit integer. (And code points that aren't a Unicode Scalar Value can't be converted into a Rust str.) See also Rust's primitive char type:
Primitive Type char
A character type.
The
chartype represents a single character. More specifically, since ‘character’ isn’t a well-defined concept in Unicode,charis a ‘Unicode scalar value’.
For the difference between a code point and a grapheme cluster, see Unicode Standard Annex #29.
See also Primitive str::chars, which clarifies:
It’s important to remember that
charrepresents a Unicode Scalar Value, and might not match your idea of what a ‘character’ is. Iteration over grapheme clusters may be what you actually want. This functionality is not provided by Rust’s standard library, check crates.io instead.