Help with slice lifetime?


#1

My code is at https://is.gd/3poKJE. Would appreciate some help with the error message: cannot infer an appropriate lifetime for lifetime parameter in function call due to conflicting requirements.

Many thanks


#2

line 32 can be

 pub fn next(&'a mut self) -> Option<Token<'a>> {

just as it says in the error. Half of learning rust is learning to read error messages. It takes some practise.

If this is next from Iter, than it is more complicated.


#3

You can also elide the lifetimes from @Eh2406’s example, and write it like this (playpen):

pub fn next(&mut self) -> Option<Token>