Returns the number of characters before the given byte offset within `s`.
(s: &str, byte_index: usize)
| 80 | |
| 81 | /// Returns the number of characters before the given byte offset within `s`. |
| 82 | fn byte_index_to_char_index(s: &str, byte_index: usize) -> usize { |
| 83 | s[..byte_index].chars().count() |
| 84 | } |
| 85 | |
| 86 | /// Returns the number of characters in `s`. |
| 87 | fn char_len(s: &str) -> usize { |