//Flags used to remember if we're currently processing a word, contraction, contraction suffix or neither
letmutin_word: bool=false;
letmutin_contraction_suffix: bool=false;
//Buffer for improved performance (avoid repeated heap allocations)
letmutstarting_consonants_buffer=Vec::<u8>::with_capacity(64);//Longer than basically all English words to avoid unneeded allocations, plus the fact that this isn't the whole word
//Indexes for improved performance (avoid copying characters to use as the english_word argument for translate_word_with_style_reuse_buffers)
//However, this assumes each character is one byte, so this only works with ASCII strings
letmutslice_start_index: usize=0;//Inclusive
letmutslice_end_index: usize=0;//Exclusive
forcharacterinenglish.iter(){
ifin_word{
ifin_contraction_suffix{
ifcharacter.is_ascii_alphabetic(){
//We never translate the contraction suffix of a word, so just copy remaining letters as-is
}else{
//The contraction ended, and so too does the word
//We still want to copy the non-letter to the output though
in_contraction_suffix=false;
in_word=false;
}
pig_latin_string.push(*character);//Copy the character
slice_start_index+=1;//Keep the slice start index up to speed for later use
}else{
ifcharacter.is_ascii_alphabetic(){
//This character is part of the word, so increment the slice_end_index to include it in the slice
slice_end_index+=1;
}else{
//The word or first part of the contraction ended, so translate the word we've identified up until this point!