Unnamed repository; edit this file 'description' to name the repository.
Rollup merge of #154742 - Jules-Bertholet:casefold, r=Mark-Simulacrum
Add APIs for case folding to the standard library [Libs-api requested these](https://github.com/rust-lang/rust/pull/154287#issuecomment-4165104865), so here they are. New public API (gated behind `#[feature(casefold)]`): ```rust impl char { pub fn to_casefold(self) -> ToCasefold; } impl str { pub fn to_casefold(&self) -> String; pub fn eq_ignore_case(&self) -> bool; } pub struct ToCasefold { ... } impl Iterator for ToCasefold { type Item = char; ... } impl DoubleEndedIterator for ToCasefold { ... } impl FusedIterator for ToCasefold { } impl ExactSizeIterator for ToCasefold { ... } impl fmt::Display for ToCasefold { ... } ``` ## Notes - This only adds a negligible amount of static data to `core::unicode`. To accomplish that, we compute the case-folding for most characters as the lowercase of their uppercase; this double mapping adds some complexity to the implementation. - No normalization (e.g. NFC) is performed, so visually and semantically equivalent strings can compare unequal. - I have not put any effort into optimizing `eq_ignore_case()`; there may be a more performant implementation. - `char::eq_ignore_case()` is left to future work—it's a potential footgun, so we may want to think more deeply about how to expose and document that API. @rustbot label T-libs-api A-unicode
Jacob Pratt 6 weeks ago
parent 544c1a6 · parent 196c190 · commit c317623
0 files changed, 0 insertions, 0 deletions