@@ -2,7 +2,16 @@ mod private
22{
33 use crate :: * ;
44
5- // xxx : write setters and default
5+ /// Former of Options for searching.
6+ pub fn options < ' a , Method , Graph , Visit > ( ) -> OptionsFormer < ' a , Method , Graph , Visit >
7+ where
8+ Graph : crate :: abs:: GraphDirected < ' a > + ?Sized ,
9+ Visit : FnMut ( & ' a Graph :: Node ) ,
10+ Method : super :: Method ,
11+ {
12+ Options :: former ( )
13+ }
14+
615 /// Options for configuring a graph search.
716 #[ derive( Debug , Default , Former ) ]
817 pub struct Options < ' a , Method , Graph , Visit >
@@ -23,6 +32,37 @@ mod private
2332 pub _phantom : std:: marker:: PhantomData < ( & ' a ( ) , ) > ,
2433 }
2534
35+ impl < ' a , Method , Graph , Visit > Options < ' a , Method , Graph , Visit >
36+ where
37+ Graph : ForGraphDirected < ' a > + ?Sized ,
38+ Visit : FnMut ( & ' a Graph :: Node ) ,
39+ Method : super :: Method ,
40+ {
41+ pub fn search ( self , graph : & ' a Graph )
42+ {
43+ graph. search ( self )
44+ }
45+ }
46+
47+ // xxx : adjust Former to eliminate need in this
48+ impl < ' a , Method , Graph , Visit > OptionsFormer < ' a , Method , Graph , Visit >
49+ where
50+ Graph : ForGraphDirected < ' a > + ?Sized ,
51+ Visit : FnMut ( & ' a Graph :: Node ) ,
52+ Method : super :: Method ,
53+ {
54+ pub fn visit_set ( mut self , visit : Visit ) -> Self
55+ {
56+ self . storage . visit = Some ( visit ) ;
57+ self
58+ }
59+ pub fn method_set ( mut self , method : Method ) -> Self
60+ {
61+ self . storage . method = Some ( method ) ;
62+ self
63+ }
64+ }
65+
2666 /// Trait for performing searches on directed graphs.
2767 pub trait ForGraphDirected < ' a > : crate :: abs:: GraphDirected < ' a >
2868 {
@@ -50,7 +90,7 @@ mod private
5090 pub trait Method : Default
5191 {
5292 /// Additional options for the search method.
53- type ExtraOptions ;
93+ type ExtraOptions : Default ;
5494
5595 /// Execute the search on a graph.
5696 fn _search < ' a , Graph , Visit >
@@ -60,7 +100,7 @@ mod private
60100 )
61101 where
62102 Visit : FnMut ( & ' a Graph :: Node ) ,
63- Graph : crate :: abs :: GraphDirected < ' a > + ?Sized ,
103+ Graph : ForGraphDirected < ' a > + ?Sized ,
64104 Self : Sized ;
65105 }
66106
@@ -80,7 +120,7 @@ mod private
80120 )
81121 where
82122 Visit : FnMut ( & ' a Graph :: Node ) ,
83- Graph : crate :: abs :: GraphDirected < ' a > + ?Sized ,
123+ Graph : ForGraphDirected < ' a > + ?Sized ,
84124 {
85125 let mut visited = collection_tools:: HashSet :: new ( ) ;
86126 let mut stack = collection_tools:: Vec :: new ( ) ;
@@ -117,7 +157,7 @@ mod private
117157 )
118158 where
119159 Visit : FnMut ( & ' a Graph :: Node ) ,
120- Graph : crate :: abs :: GraphDirected < ' a > + ?Sized ,
160+ Graph : ForGraphDirected < ' a > + ?Sized ,
121161 {
122162 let mut visited = collection_tools:: HashSet :: new ( ) ;
123163 let mut queue = collection_tools:: VecDeque :: new ( ) ;
@@ -144,6 +184,7 @@ crate::mod_interface!
144184{
145185 own use
146186 {
187+ options,
147188 Method ,
148189 Options ,
149190 ForGraphDirected ,
0 commit comments