Returns the byte offset of the given character position within `s`.
(s: &str, char_index: usize)
| 75 | |
| 76 | /// Returns the byte offset of the given character position within `s`. |
| 77 | fn char_index_to_byte_index(s: &str, char_index: usize) -> usize { |
| 78 | s.char_indices().nth(char_index).map(|(i, _)| i).unwrap_or(s.len()) |
| 79 | } |
| 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 { |
no test coverage detected