Proposal
Problem statement
There is no way to itererate over lowercase/uppercase chars of a &str without creating full copy of it with str::to_lowercase
or str::to_uppercase.
But there exists a bad way: str::chars with char::to_lowercase. The problem is that the latter API cannot match output of str::to_lowercase or str::to_uppercase as some Unicode conversions require context and that API cannot provide it.
Motivation, use-cases
Reason for avoiding call to str::to_lowercase() and str::to_uppercase:
no_std
- performance
- lazy operation - only few chars are needed.
Reasons to avoid char::to_uppercase and char::to_lowercase:
Solution sketches
Solution A:
str::chars_lowercase() -> CharsLowercase
str::chars_uppercase() -> CharsUppercase
Solution B:
char::to_lowercase_with_context(&str, usize) -> ToLowercase
char::to_uppercase_with_context(&str, usize) -> ToUppercase
Links and related work
PR for solution A: rust-lang/rust#98490
Proposal
Problem statement
There is no way to itererate over lowercase/uppercase chars of a
&strwithout creating full copy of it withstr::to_lowercaseor
str::to_uppercase.But there exists a bad way:
str::charswithchar::to_lowercase. The problem is that the latter API cannot match output ofstr::to_lowercaseorstr::to_uppercaseas some Unicode conversions require context and that API cannot provide it.Motivation, use-cases
Reason for avoiding call to
str::to_lowercase()andstr::to_uppercase:no_stdReasons to avoid
char::to_uppercaseandchar::to_lowercase:Solution sketches
Solution A:
str::chars_lowercase() -> CharsLowercasestr::chars_uppercase() -> CharsUppercaseSolution B:
char::to_lowercase_with_context(&str, usize) -> ToLowercasechar::to_uppercase_with_context(&str, usize) -> ToUppercaseLinks and related work
PR for solution A: rust-lang/rust#98490