Add PartialEq and Eq impls to the character case iterators#154287
Add PartialEq and Eq impls to the character case iterators#154287Jules-Bertholet wants to merge 2 commits intorust-lang:mainfrom
PartialEq and Eq impls to the character case iterators#154287Conversation
Allows easily checking whether a string is in a particular case.
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
And also add a test for its claims.
35b6f10 to
831794e
Compare
Isn't this done with |
Those methods do not currently exist. It might make sense to add e.g.
Not that I know of. However, |
|
Hm, okay. I think that makes some sense. Let's see what libs-api thinks (should be in their meeting queue). |
|
An additional minor benefit of the proposed API is that it would allow removing |
|
It seems T-libs-api wasn't a fan of this, and had some alternative suggestions (https://hackmd.io/3iG4g-ofShaMgcP_OYHCEw#waiting-on-team-rusttf154287-Add-PartialEq-and-Eq-impls-to-the-character-case-iterators). I'll go through them one by one:
I would be open to adding those. However, as I explained above, they don't extend neatly to titlecase. Also, they don't work for people who can't easily use It doesn't necessarily have to be this PR's API, however. For example, we could have methods on
Overhead should not be a problem. Case folding is primarily based on the lowercase mapping, so we would only need a small table for the difference. However, there are other issues:
It doesn't optimize well, unfortunately. |
|
We discussed this PR in this week's @rust-lang/libs-api meeting and decided against this proposal. We would, however, be open to addressing this usecase through any or all of adding |
Allows easily checking whether a string is in a particular case.
Adds
impl PartialEq<{ToUppercase, ToLowercase, ToTitlecase, char}> for {ToUppercase, ToLowercase, ToTitlecase}andimpl Eq for {ToUppercase, ToLowercase, ToTitlecase}.@rustbot label needs-fcp T-libs-api A-unicode