Skip to content

Question about "lifetime mismatch" #295

Answered by kevinmehall
piggynl asked this question in Q&A
Discussion options

You must be logged in to vote

This is pretty similar to #291.

You can make it compile if you get the lifetimes just right:

--- a/src/main.rs
+++ b/src/main.rs
@@ -17,9 +17,9 @@
     fn position_repr(&self, p: usize) -> Self::PositionRepr { p }
 }
 
-impl<'parse: 'lex, 'lex> ParseElem<'parse> for LexerResult<'lex>
+impl<'parse, 'lex: 'parse> ParseElem<'parse> for LexerResult<'lex>
 {
-    type Element = &'lex Token<'lex>;
+    type Element = &'parse Token<'lex>;
 
     fn parse_elem(&'parse self, pos: usize) -> RuleResult<Self::Element> {
         match self.0.get(pos) {
@@ -33,7 +33,7 @@
     grammar parser<'lex>() for LexerResult<'lex> {
         rule keyword() = [&Token::Keyword]
 
-        rule name() -> Vec<&'lex …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@piggynl
Comment options

Answer selected by piggynl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants