Trait UnicodeCaseFold

Source
pub trait UnicodeCaseFold<I: Iterator<Item = char>>: Sized {
    // Required method
    fn case_fold_with(self, _: Variant, _: Locale) -> CaseFold<I> ;

    // Provided method
    fn case_fold(self) -> CaseFold<I>  { ... }
}
Expand description

Methods for case folding text.

Required Methods§

Source

fn case_fold_with(self, _: Variant, _: Locale) -> CaseFold<I>

Returns an iterator over the case folded characters of self.

§Parameters

The Variant can be either:

  • Variant::Full (recommended), which may expand to a longer string. For example, the full case folded version of ß (one character) is ss (two characters).

  • Variant::Simple, a simpler variant which always expands to a string with the same number of characters. This is more efficient, but less complete.

The Locale can be either:

  • Locale::NonTurkic (default), which maps I to i.

  • Locale::Turkic, which maps I to ı (dotless i), as is the case in Turkic languages.

§Examples
let name = "Inigo Montoya";
let turkic = name.case_fold_with(Variant::Full, Locale::Turkic).collect::<String>();
let non_turkic = name.case_fold_with(Variant::Full, Locale::NonTurkic).collect::<String>();
assert_eq!(turkic, "ınigo montoya");  // note the dotless i
assert_eq!(non_turkic, "inigo montoya");

Provided Methods§

Source

fn case_fold(self) -> CaseFold<I>

Returns an iterator over the case folded characters of self.

This is a convenient shorthand for .case_fold(Variant::Full, Locale::NonTurkic).

§Examples
let s = "Alan Turing".case_fold().collect::<String>();
assert_eq!(s, "alan turing");

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl UnicodeCaseFold<Once<char>> for char

Source§

fn case_fold_with( self, variant: Variant, locale: Locale, ) -> CaseFold<Once<char>>

Source§

impl<'a> UnicodeCaseFold<Chars<'a>> for &'a str

Source§

fn case_fold_with(self, variant: Variant, locale: Locale) -> CaseFold<Chars<'a>>

Implementors§

Source§

impl<I: Iterator<Item = char>> UnicodeCaseFold<I> for I