alamb commented on code in PR #1626:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1626#discussion_r1898911096


##########
src/parser/mod.rs:
##########
@@ -3729,27 +3729,6 @@ impl<'a> Parser<'a> {
         }
     }
 
-    /// If the current token is the `expected` keyword, consume it and returns
-    ///
-    /// See [`Self::parse_keyword_token_ref`] to avoid the copy.
-    #[must_use]
-    pub fn parse_keyword_token(&mut self, expected: Keyword) -> 
Option<TokenWithSpan> {
-        self.parse_keyword_token_ref(expected).cloned()
-    }
-
-    /// If the current token is the `expected` keyword, consume it and returns 
a reference to the next token.
-    ///
-    #[must_use]
-    pub fn parse_keyword_token_ref(&mut self, expected: Keyword) -> 
Option<&TokenWithSpan> {

Review Comment:
   as discussed on https://github.com/apache/datafusion-sqlparser-rs/pull/1618, 
the fact this takes `&mut self` makes avoiding clones challenging (because as 
long as &TokenWithSpan) is around, rust treats the parser as borrowed mutably 
(and you can't call other APIs)



##########
src/parser/mod.rs:
##########
@@ -3832,9 +3811,11 @@ impl<'a> Parser<'a> {
 
     /// If the current token is the `expected` keyword, consume the token.
     /// Otherwise, return an error.
+    ///
+    // todo deprecate infavor of expected_keyword_is
     pub fn expect_keyword(&mut self, expected: Keyword) -> 
Result<TokenWithSpan, ParserError> {
-        if let Some(token) = self.parse_keyword_token_ref(expected) {
-            Ok(token.clone())
+        if self.parse_keyword(expected) {

Review Comment:
   I actually think using `parse_keyword` and `get_current_token` is clearer 
than the original formulation of `paser_keyword_token_ref` and checking for 
`Some`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to