@@ -2822,6 +2822,9 @@ impl str {
28222822 /// Same as `to_ascii_lowercase(a) == to_ascii_lowercase(b)`,
28232823 /// but without allocating and copying temporaries.
28242824 ///
2825+ /// For Unicode-aware case-insensitive matching, consider
2826+ /// [`str::eq_ignore_case`].
2827+ ///
28252828 /// # Examples
28262829 ///
28272830 /// ```
@@ -2837,6 +2840,38 @@ impl str {
28372840 self . as_bytes ( ) . eq_ignore_ascii_case ( other. as_bytes ( ) )
28382841 }
28392842
2843+ /// Checks that two strings are a caseless match, according to
2844+ /// [Definition 144] in Chapter 3 of the Unicode Standard.
2845+ ///
2846+ /// [Definition 144]: https://www.unicode.org/versions/latest/core-spec/chapter-3/#G53513
2847+ ///
2848+ /// Same as `a.to_casefold() == b.to_casefold()`,
2849+ /// but without allocating. See that method's documentation,
2850+ /// and [`char::to_casefold()`],
2851+ /// for more information about case folding.
2852+ ///
2853+ /// No normalization (e.g. NFC) is performed,
2854+ /// so visually and semantically identical strings
2855+ /// might still compare unequal. In addition,
2856+ /// this method is independent of language/locale,
2857+ /// so the special behavior of I/ı/İ/i
2858+ /// in Turkish and Azeri is not handled.
2859+ ///
2860+ /// # Examples
2861+ ///
2862+ /// ```
2863+ /// #![feature(casefold)]
2864+ /// assert!("Ferris".eq_ignore_case("FERRIS"));
2865+ /// assert!("Ferrös".eq_ignore_case("FERRÖS"));
2866+ /// assert!("ẞ".eq_ignore_case("ss"));
2867+ /// ```
2868+ #[ unstable( feature = "casefold" , issue = "none" ) ]
2869+ #[ must_use]
2870+ #[ inline]
2871+ pub fn eq_ignore_case ( & self , other : & str ) -> bool {
2872+ self . chars ( ) . flat_map ( char:: to_casefold) . eq ( other. chars ( ) . flat_map ( char:: to_casefold) )
2873+ }
2874+
28402875 /// Converts this string to its ASCII upper case equivalent in-place.
28412876 ///
28422877 /// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
0 commit comments