Implementing Lifetimes for an Iterator

Could somebody explain to me where I need to include the lifetime parameters here. Thanks.

pub struct Token<'a> {
    typ: TokenType,
    val: &'a str
}

impl Iterator for Lexer {
    type Item = Token;
    	
    fn next(&mut self) -> Option<Token> {
    		// lala
impl<'a> Iterator for Lexer<'a> {
    type Item = Token<'a>;

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

Basically, the Lexer has a reference to a string, and each token has a reference to the same string. (Whether this is actually usable depends on the implementation of Lexer, of course.)

1 Like

Thanks!