pub(crate) fn word_range_for_pos(text: &str, pos: usize) -> Range<usize> {
    text.split_word_bound_indices()
        .map(|(ix, word)| ix..(ix + word.len()))
        .find(|range| range.contains(&pos))
        .unwrap_or(pos..pos)
}
/// Given a position in some text, return the containing word boundaries.
///
/// The returned range may not necessary be a 'word'; for instance it could be
/// the sequence of whitespace between two words.
///
/// If the position is on a word boundary, that will be considered the start
/// of the range.
///
/// This uses Unicode word boundaries, as defined in [UAX#29].
///
/// [UAX#29]: http://www.unicode.org/reports/tr29/
Given a position in some text, return the containing word boundaries.
The returned range may not necessary be a 'word'; for instance it could be
the sequence of whitespace between two words.

If the position is on a word boundary, that will be considered the start
of the range.

This uses Unicode word boundaries, as defined in [UAX#29].


Given a position in some text return the containing word boundaries . The returned range may not necessary be a ' word ' ; for instance it could be the sequence of whitespace between two words . If the position is on a word boundary that will be considered the start of the range . This uses Unicode word boundaries as defined in [ UAX#29 ] .
pub(crate) fn word_range_for_pos(text: &str, pos: usize) -> Range<usize> {
    text.split_word_bound_indices()
        .map(|(ix, word)| ix..(ix + word.len()))
        .find(|range| range.contains(&pos))
        .unwrap_or(pos..pos)
}
pub ( crate ) fn word_range_for_pos ( text : & str , pos : usize ) -> Range < usize > { text . split_word_bound_indices ( ) . map ( | ( ix , word ) | ix .. ( ix + word . len ( ) ) ) . find ( | range | range . contains ( & pos ) ) . unwrap_or ( pos .. pos ) }
Given a position in some text, return the containing word boundaries.
Given a position in some text return the containing word boundaries .
text
&str
pos
usize
text
&str
pos
usize