Skip to content
Discussion options

You must be logged in to vote

btw you most likely need something like

#[derive(Debug, Clone, PartialEq)]
pub enum Literal<'a> {
    String(Cow<'a, str>),
    Integer(i64),
    Decimal(f64),
    Boolean(bool),
}

impl<'a> Literal<'a> {
    pub(crate) fn parse<'i, 's>(input: &'i mut StatefulInput<'a, 's>) -> ModalResult<Literal<'a>> {
        alt((
            string::parse.map(Literal::String), // Error here
            decimal::parse.map(Literal::Decimal),
            integer::parse.map(Literal::Integer),
            boolean::parse.map(Literal::Boolean),
        ))
        .parse_next(input)
    }
}

I've generally found that once lifetimes are involved, you have to explicitly state your mutable-ref lifetime.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

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

Answer selected by decipher3114
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