From dc8d5d2f1eadb19d0351fa214400d7ec7ba31a20 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 2 Oct 2020 20:22:08 +0200 Subject: =?UTF-8?q?Small=20improvements=20=F0=9F=A7=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parse/parser.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/parse/parser.rs') diff --git a/src/parse/parser.rs b/src/parse/parser.rs index d34730c8..041a61bc 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -228,7 +228,7 @@ impl<'s> Parser<'s> { /// /// Returns `false` if there is no next token. pub fn check(&mut self, f: impl FnOnce(Token<'s>) -> bool) -> bool { - self.peek().map(f).unwrap_or(false) + self.peek().map_or(false, f) } /// Whether the end of the source string or group is reached. @@ -278,7 +278,9 @@ impl<'s> Parser<'s> { /// Set the position to the tokenizer's position and take the peeked token. fn bump(&mut self) -> Option> { self.pos = self.tokens.pos(); - self.peeked.take() + let token = self.peeked; + self.peeked = None; + token } } -- cgit v1.2.3