(s: &str, n_chars: usize)
| 365 | |
| 366 | #[inline] |
| 367 | pub fn char_range_end(s: &str, n_chars: usize) -> Option<usize> { |
| 368 | let i = match n_chars.checked_sub(1) { |
| 369 | Some(last_char_index) => { |
| 370 | let (index, c) = s.char_indices().nth(last_char_index)?; |
| 371 | index + c.len_utf8() |
| 372 | } |
| 373 | None => 0, |
| 374 | }; |
| 375 | Some(i) |
| 376 | } |
| 377 | |
| 378 | pub fn try_get_codepoints(w: &Wtf8, range: impl RangeBounds<usize>) -> Option<&Wtf8> { |
| 379 | let mut chars = w.code_points(); |