mod util; use util::cube::PocketCube; use util::dfs::DepthFirstSearch; use rayon::iter::plumbing::{bridge_unindexed, Folder, UnindexedConsumer, UnindexedProducer}; use rayon::iter::ParallelIterator; impl UnindexedProducer for DepthFirstSearch { type Item = ::Item; fn split(mut self) -> (Self, Option) { let split = self.try_split(); (self, split) } fn fold_with(self, folder: F) -> F where F: Folder, { folder.consume_iter(self) } } impl ParallelIterator for DepthFirstSearch { type Item = ::Item; fn drive_unindexed(self, consumer: C) -> C::Result where C: UnindexedConsumer, { bridge_unindexed(self, consumer) } } fn main() { let impossible = PocketCube::impossible(); let cubes = DepthFirstSearch::new(PocketCube::solved()); assert!(cubes.all(|cube| cube != impossible)); }