Hello,
I'm using nom to write parsers and have a bunch of parsers with signatures like these:
use nom::Parser;
pub(crate) fn identifier<'a>() -> impl Parser<&'a str, Expression, VerboseError<&'a str>> {
...
}
All parsers have similar return types. The only thing that varies is the Expression
part. So, I want to use a type alias like this:
type MParser<'a, O> = Parser<&'a str, O, VerboseError<&'a str>>;
But I can't figure out how to rewrite the functions using this alias. If I include impl
in the alias, I get an error "impl Trait
in type aliases is unstable", and if I try to write the impl
in front of the alias in the function definition, it complains that impl
cannot be followed by an alias. Without impl
, it fails because it is not Sized
. Is there a way? Thanks!
Best, Oliver