I've created a trait for a parser, and I want to auto implement that trait for every function that matches the core function description. Not too hard, but unfortunately one of the parameters has a lifetime attached, (a wrapper around a Chars iterator)
pub type ParseRes<'a, V> = Result<(LCChars<'a>, V), ParseError>;
pub trait Parser<V>: Sized {
fn parse<'a>(&self, i: &LCChars<'a>) -> ParseRes<'a, V>;
//...
}
However when I create the auto implement:
impl<'a, V, F: Fn(&LCChars<'a>) -> ParseRes<'a, V>> Parser<V> for F {
fn parse<'b>(&self, i: &LCChars<'b>) -> ParseRes<'b, V> {
self(i)
}
}
I can't make the "b"s match the "a"s to make the function work
If I make it all "a", then it complains that "a" is shaddowed.
If I get rid of the shaddow "a" abut leave it all as "a" then it doesn't match the trait.
Any ideas?
Thanks
Matt