tree: add tree branch reference

allow multiple independent iterators for the same underlying tree

safety: not very good, but should work because original tree is kept in
Parser and branches are only used during its lifetime
This commit is contained in:
Noah Hellman 2023-01-18 21:33:55 +01:00
parent 4a7967812e
commit c7b3aa560b
3 changed files with 39 additions and 31 deletions

View file

@ -418,7 +418,7 @@ mod test {
macro_rules! test_parse {
($src:expr $(,$($event:expr),* $(,)?)?) => {
let t = super::TreeParser::new($src).parse();
let actual = t.map(|ev| (ev.kind, ev.span.of($src))).collect::<Vec<_>>();
let actual = t.root().map(|ev| (ev.kind, ev.span.of($src))).collect::<Vec<_>>();
let expected = &[$($($event),*,)?];
assert_eq!(actual, expected, "\n\n{}\n\n", $src);
};