-
Notifications
You must be signed in to change notification settings - Fork 612
Use Token::EOF instead of Option<Token> #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The clone kludge in `_ => self.expected("date/time field", Token::Word(w.clone())))` will become unnecessary once we stop using a separate match for the keywords, as suggested in https://github.com/andygrove/sqlparser-rs/pull/193#issuecomment-641607194
Pull Request Test Coverage Report for Build 130885271
💛 - Coveralls |
I like two thing about this change:
|
self.peek_nth_token(0) | ||
} | ||
|
||
/// Return nth non-whitespace token that has not yet been processed | ||
pub fn peek_nth_token(&self, mut n: usize) -> Option<Token> { | ||
pub fn peek_nth_token(&self, mut n: usize) -> Token { | ||
let mut index = self.index; | ||
loop { | ||
index += 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This index += 1 I think would be better at the and of the loop
so it can be just self.tokens.get(index)
, or convert to a normal for loop?
(just looking at the code surrounding the changes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a continue
later on, so moving it below won't work. If you have suggestions for improvements, feel free to raise separate PRs.
This simplifies codes slightly, removing the need deal with the EOF case explicitly.
@Dandandan what do you think?