From 5a500fb8a7c0ba4b8a59e2622c8cbafdc4ce1fe9 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 8 Jul 2021 19:12:07 +0200 Subject: Range operator --- src/parse/scanner.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/parse/scanner.rs') diff --git a/src/parse/scanner.rs b/src/parse/scanner.rs index d2c2efed..1a0e3045 100644 --- a/src/parse/scanner.rs +++ b/src/parse/scanner.rs @@ -86,11 +86,6 @@ impl<'s> Scanner<'s> { self.rest().chars().next() } - /// Peek at the nth-next char without consuming anything. - pub fn peek_nth(&self, n: usize) -> Option { - self.rest().chars().nth(n) - } - /// Checks whether the next char fulfills a condition. /// /// Returns `false` if there is no next char. @@ -101,6 +96,11 @@ impl<'s> Scanner<'s> { self.peek().map(f).unwrap_or(false) } + /// Checks whether the remaining source starts with the given string. + pub fn starts_with(&self, string: &str) -> bool { + self.rest().starts_with(string) + } + /// The previous index in the source string. pub fn last_index(&self) -> usize { self.eaten() -- cgit v1.2.3