pub fn split_words(s: &str) -> Vec<&str> {
    let mut res = vec![];
    let mut word_start = None;
    for (idx, c) in s.char_indices() {
        if c.is_alphanumeric() {
            if word_start.is_none() {
                word_start = Some(idx);
            }
        } else {
            if let Some(start) = word_start {
                res.push(&s[start..idx]);
                word_start = None;
            }
            res.push(&s[idx..idx + c.len_utf8()]);
        }
    }

    if let Some(start) = word_start {
        res.push(&s[start..]);
    }
    res
}
/// Split `s` into a vec of things that look like words and individual
/// non-word characters.
///
/// "foo bar" -> vec!["foo", " ", "bar"]
Split `s` into a vec of things that look like words and individual
non-word characters.


Split ` s ` into a vec of things that look like words and individual non - word characters .
pub fn split_words(s: &str) -> Vec<&str> {
    let mut res = vec![];
    let mut word_start = None;
    for (idx, c) in s.char_indices() {
        if c.is_alphanumeric() {
            if word_start.is_none() {
                word_start = Some(idx);
            }
        } else {
            if let Some(start) = word_start {
                res.push(&s[start..idx]);
                word_start = None;
            }
            res.push(&s[idx..idx + c.len_utf8()]);
        }
    }
    if let Some(start) = word_start {
        res.push(&s[start..]);
    }
    res
}
pub fn split_words ( s : & str ) -> Vec < & str > { let mut res = vec ! [ ] ; let mut word_start = None ; for ( idx , c ) in s . char_indices ( ) { if c . is_alphanumeric ( ) { if word_start . is_none ( ) { word_start = Some ( idx ) ; } } else { if let Some ( start ) = word_start { res . push ( & s [ start .. idx ] ) ; word_start = None ; } res . push ( & s [ idx .. idx + c . len_utf8 ( ) ] ) ; } } if let Some ( start ) = word_start { res . push ( & s [ start .. ] ) ; } res }
Split `s` into a vec of things that look like words and individual
non-word characters.
Split ` s ` into a vec of things that look like words and individual non - word characters .
s
&str