Skip to content

Parser doesn't compile as Stateful parser when used with other combinators (missing lifetime) #646

Closed Answered by epage
35VLG84 asked this question in Q&A
Discussion options

You must be logged in to vote
pub fn identifier<'s>(input: &mut &'s str) -> PResult<&'s str> {
// vs
pub fn identifier<'is>(is:  &'is mut InputState) -> PResult<&'is str> {

A key difference between these is of lifetimes. The signature should be

pub fn identifier<'is>(is:  &mut InputState<'is>) -> PResult<&'is str> {

I'd recommend having the following in your Cargo.toml file:

[package.lints.rust]
rust_2018_idioms = { level = "warn", priority = -1 }

As it would highlight that InputState did not have a lifetime specified (even if it can usually be <'_>). This likely would have made the difference in lifetimes more obvious.

Replies: 2 comments 1 reply

Comment options

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

Answer selected by 35VLG84
Comment options

You must be logged in to vote
0 replies
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