Skip to main content

extract_trigrams

Function extract_trigrams 

Source
pub fn extract_trigrams(text: &str) -> Vec<[u8; 3]>
Expand description

Extract overlapping 3-byte windows from text, handling invalid UTF-8 with lossy replacement.

Valid UTF-8 takes a fast path (no replacement string allocated). Invalid sequences fall back to String::from_utf8_lossy semantics, matching what [extract_trigrams_utf8_lossy] would do on the raw bytes — but in a single pass without an intermediate String.