(string: &str, n: i64)
| 115 | /// Calculate the byte length of the substring of `n` chars from string `string` |
| 116 | #[inline] |
| 117 | fn left_right_byte_length(string: &str, n: i64) -> usize { |
| 118 | match n.cmp(&0) { |
| 119 | Ordering::Less => string |
| 120 | .char_indices() |
| 121 | .nth_back((n.unsigned_abs().min(usize::MAX as u64) - 1) as usize) |
| 122 | .map(|(index, _)| index) |
| 123 | .unwrap_or(0), |
| 124 | Ordering::Equal => 0, |
| 125 | Ordering::Greater => { |
| 126 | byte_offset_of_char(string, n.unsigned_abs().min(usize::MAX as u64) as usize) |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | /// General implementation for `left` and `right` functions |
| 132 | pub(crate) fn general_left_right<F: LeftRightSlicer>( |
no test coverage detected
searching dependent graphs…