Trait unicode_casefold::UnicodeCaseFold
[−]
[src]
pub trait UnicodeCaseFold<I: Iterator<Item = char>>: Sized { fn case_fold_with(self, _: Variant, _: Locale) -> CaseFold<I>; fn case_fold(self) -> CaseFold<I> { ... } }
Methods for case folding text.
Required Methods
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) isss
(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 mapsI
toi
.Locale::Turkic
, which mapsI
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
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");