-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Description
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:
- corretctness.
Solution sketches
Solution A:
str::chars_lowercase() -> CharsLowercasestr::chars_uppercase() -> CharsUppercase
Solution B:
char::to_lowercase_with_context(&str, usize) -> ToLowercasechar::to_uppercase_with_context(&str, usize) -> ToUppercase
Links and related work
PR for solution A: rust-lang/rust#98490
Metadata
Metadata
Assignees
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries