diff --git a/apb/src/node.rs b/apb/src/node.rs index c1244e9..d8b427a 100644 --- a/apb/src/node.rs +++ b/apb/src/node.rs @@ -116,6 +116,15 @@ impl Node { Node::Array(x) => x.iter().filter_map(Self::id).collect() } } + + pub fn flat(self) -> Vec> { + match self { + Node::Empty => vec![], + Node::Link(_) | Node::Object(_) => vec![self], + // i think AP disallows array of arrays so no need to make this recursive + Node::Array(arr) => arr.into() + } + } } #[cfg(feature = "unstructured")]