(string: &str, n: usize)
| 83 | /// or `string.len()` if the string has fewer than `n` codepoints. |
| 84 | #[inline] |
| 85 | pub(crate) fn byte_offset_of_char(string: &str, n: usize) -> usize { |
| 86 | string |
| 87 | .char_indices() |
| 88 | .nth(n) |
| 89 | .map_or(string.len(), |(i, _)| i) |
| 90 | } |
| 91 | |
| 92 | /// If `string` has more than `n` codepoints, returns the byte offset of |
| 93 | /// the `n`-th codepoint boundary. Otherwise returns the total codepoint count. |
no test coverage detected
searching dependent graphs…