2 ms·
Where my mind personally goes is to return a Token struct on each iteration instead of a &str. This can still have the same lifetime guarantees, though: stru
by brundolf 6y ago
Where my mind personally goes is to return a Token struct on each iteration instead of a &str. This can still have the same lifetime guarantees, though:
struct Token<'a> {
s: &'a str,
start_index: usize,
}
I believe you can get the len() of a &str, so you could just store the start index and derive the end index.