Looks ahead at the next N characters without consuming them
(&self, n: usize)
| 276 | |
| 277 | // Looks ahead at the next N characters without consuming them |
| 278 | fn check_next(&self, n: usize) -> Option<&str> { |
| 279 | let mut chars = self.source[self.current..].char_indices(); |
| 280 | match chars.nth(n - 1) { |
| 281 | Some((end_offset, ch)) => { |
| 282 | let end = self.current + end_offset + ch.len_utf8(); |
| 283 | if end <= self.source.len() { |
| 284 | Some(&self.source[self.current..end]) |
| 285 | } else { |
| 286 | None |
| 287 | } |
| 288 | } |
| 289 | None => None, |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | // Returns the next 2 characters as a string slice |
| 294 | fn next2(&mut self) -> &str { |
no test coverage detected