Partition the tree, this looks for the first context frame, then moves it up the chain and adds it to our results. Once we reach the end all remaining items on the stack are added to the prefix pile, which will be used in next iteration.
(stack: &'a [&'a Frame])
| 761 | /// Once we reach the end all remaining items on the stack are added to the prefix pile, |
| 762 | /// which will be used in next iteration. |
| 763 | fn partition<'a>(stack: &'a [&'a Frame]) -> (Vec<(&'a Frame, Vec<&'a Frame>)>, Vec<&'a Frame>) { |
| 764 | let mut result = vec![]; |
| 765 | let mut queue = vec![]; |
| 766 | |
| 767 | for frame in stack { |
| 768 | if matches!(frame.kind(), FrameKind::Context(_)) { |
| 769 | let frames = mem::take(&mut queue); |
| 770 | |
| 771 | result.push((*frame, frames)); |
| 772 | } else { |
| 773 | queue.push(*frame); |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | (result, queue) |
| 778 | } |
| 779 | |
| 780 | fn debug_context(context: &(dyn Error + Send + Sync + 'static), mode: ColorMode) -> Lines { |
| 781 | context |
no test coverage detected