diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-02 20:22:08 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-02 20:22:08 +0200 |
| commit | dc8d5d2f1eadb19d0351fa214400d7ec7ba31a20 (patch) | |
| tree | 64c0ebb599c480270ac529edbc14b02534853828 /src/parse/parser.rs | |
| parent | 904bc392abdcd7c48fa4541594f6218168afb61f (diff) | |
Small improvements 🧺
Diffstat (limited to 'src/parse/parser.rs')
| -rw-r--r-- | src/parse/parser.rs | 6 |
1 files changed, 4 insertions, 2 deletions
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<Token<'s>> { self.pos = self.tokens.pos(); - self.peeked.take() + let token = self.peeked; + self.peeked = None; + token } } |
