MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / check_next

Method check_next

aiscript-lexer/src/lib.rs:278–291  ·  view source on GitHub ↗

Looks ahead at the next N characters without consuming them

(&self, n: usize)

Source from the content-addressed store, hash-verified

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 {

Callers 4

scan_tokenMethod · 0.80
enum_declarationMethod · 0.80
class_declarationMethod · 0.80
func_declarationMethod · 0.80

Calls 3

nthMethod · 0.80
lenMethod · 0.80
peek_nextMethod · 0.80

Tested by

no test coverage detected