use super::graph_store::{GraphNode, GraphStore}; /// A graph traversal that does not guarantee any particular order, and may not /// return the same order every time it is run. pub struct NonDeterministic { output: Vec, } impl Default for NonDeterministic { fn default() -> Self { Self::new() } } impl NonDeterministic { pub fn new() -> Self { Self { output: Vec::new() } } } impl GraphStore for NonDeterministic where T: Send, { type Node = T; type Handle = (); fn insert( &mut self, _from_handle: Option, node: GraphNode, ) -> Option<(Self::Handle, &T)> { self.output.push(node.into_node()); Some(((), self.output.last().unwrap())) } } impl IntoIterator for NonDeterministic { type Item = T; type IntoIter = as IntoIterator>::IntoIter; fn into_iter(self) -> Self::IntoIter { self.output.into_iter() } }