(s: &Wtf8, n_chars: usize)
| 400 | |
| 401 | #[inline] |
| 402 | pub fn codepoint_range_end(s: &Wtf8, n_chars: usize) -> Option<usize> { |
| 403 | let i = match n_chars.checked_sub(1) { |
| 404 | Some(last_char_index) => { |
| 405 | let (index, c) = s.code_point_indices().nth(last_char_index)?; |
| 406 | index + c.len_wtf8() |
| 407 | } |
| 408 | None => 0, |
| 409 | }; |
| 410 | Some(i) |
| 411 | } |
| 412 | |
| 413 | pub fn zfill(bytes: &[u8], width: usize) -> Vec<u8> { |
| 414 | if width <= bytes.len() { |
no test coverage detected