1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
use super::{Id, Items, Neighbors}; use petgraph::visit; use std::collections::HashSet; impl visit::GraphBase for Items { type EdgeId = (); type NodeId = Id; } impl visit::Visitable for Items { type Map = HashSet<Id>; #[inline] fn visit_map(&self) -> Self::Map { HashSet::with_capacity(self.items.len()) } #[inline] fn reset_map(&self, map: &mut Self::Map) { map.clear(); } } impl<'a> visit::IntoNeighbors for &'a Items { type Neighbors = Neighbors<'a>; #[inline] fn neighbors(self, id: Id) -> Self::Neighbors { self.neighbors(id) } } impl visit::NodeCount for Items { #[inline] fn node_count(&self) -> usize { self.items.len() } }