clap/
strext.rs

1pub trait _StrExt {
2    fn _is_char_boundary(&self, index: usize) -> bool;
3}
4
5impl _StrExt for str {
6    #[inline]
7    fn _is_char_boundary(&self, index: usize) -> bool {
8        if index == self.len() {
9            return true;
10        }
11        match self.as_bytes().get(index) {
12            None => false,
13            Some(&b) => !(128..192).contains(&b),
14        }
15    }
16}