Loading RustViz Engine...
Solve the self-referential lifetime limitation by storing range indices instead of references.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
pub struct TokenBuffer {
data: String,
tokens: Vec<(usize, usize)>,
}
impl TokenBuffer {
pub fn get_token(&self, index: usize) -> Option<&str> {
let &(start, end) = self.tokens.get(index)?;
Some(&self.data[start..end])
}
}