Skip to main content

casefold

Function casefold 

Source
pub fn casefold<'a>(input: &'a str, mode: CaseFoldMode) -> Cow<'a, str>
Expand description

Fold a string using simple case folding.

Returns Cow::Borrowed if the string is already fully case-folded (no characters changed).

In CaseFoldMode::Standard, the implementation runs an ASCII fast path: 64-byte chunks are scanned via the dispatched SIMD scanner with bound 0x80. Chunks with zero non-ASCII bytes get a scalar mask | 0x20-style lowercase pass (no per-byte trie lookup), which dominates throughput on ASCII / Latin-1 inputs. Non-ASCII chunks fall back to the per-codepoint trie-driven path. Other modes (Turkish, etc.) skip the fast path because their override rules apply within the ASCII range.