I was looking at the source code of Rust, and found this function.
pub fn tokenize(input: &str) -> impl Iterator<Item = Token> + '_ {
let mut cursor = Cursor::new(input);
std::iter::from_fn(move || {
if cursor.is_eof() {
None
} else {
cursor.reset_len_consumed();
Some(cursor.advance_token())
}
})
}
I understand that '_ refers to an anonymous lifetime, but I'm not sure what it means in this context. Would love to get some clarification on this. Thanks.