Collect the current "stack", a stack are the current frames which only have a single source/parent. This searches until it finds a stack "split", where a frame has more than a single source.
(root: &'a Frame, prefix: &'a [&Frame])
| 732 | /// source/parent. |
| 733 | /// This searches until it finds a stack "split", where a frame has more than a single source. |
| 734 | fn collect<'a>(root: &'a Frame, prefix: &'a [&Frame]) -> (Vec<&'a Frame>, &'a [Frame]) { |
| 735 | let mut stack = vec![]; |
| 736 | stack.extend(prefix); |
| 737 | stack.push(root); |
| 738 | |
| 739 | let mut ptr = Some(root); |
| 740 | let mut next: &'a [_] = &[]; |
| 741 | |
| 742 | while let Some(current) = ptr.take() { |
| 743 | let sources = current.sources(); |
| 744 | |
| 745 | match sources { |
| 746 | [parent] => { |
| 747 | stack.push(parent); |
| 748 | ptr = Some(parent); |
| 749 | } |
| 750 | sources => { |
| 751 | next = sources; |
| 752 | } |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | (stack, next) |
| 757 | } |
| 758 | |
| 759 | /// Partition the tree, this looks for the first context frame, |
| 760 | /// then moves it up the chain and adds it to our results. |
no test coverage detected