MCPcopy Create free account
hub / github.com/hashintel/hash / collect

Function collect

libs/error-stack/src/fmt/mod.rs:734–757  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

732/// source/parent.
733/// This searches until it finds a stack "split", where a frame has more than a single source.
734fn 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.

Callers 2

debug_frameFunction · 0.70
try_process_reportsFunction · 0.50

Calls 4

sourcesMethod · 0.80
pushMethod · 0.65
extendMethod · 0.45
takeMethod · 0.45

Tested by

no test coverage detected