@@ -60,9 +60,9 @@ impl TabryConf {
60
60
let mut result = vec ! [ & self . main] ;
61
61
62
62
for name in sub_names_vec {
63
- let sub = result. last ( ) . unwrap ( ) ;
63
+ let subs_here = & result. last ( ) . unwrap ( ) . subs ;
64
64
let next =
65
- self . find_in_subs ( & sub . subs , & sub . includes , name, false ) ?
65
+ self . find_in_subs ( subs_here , name, false ) ?
66
66
. ok_or ( TabryConfError :: InternalError (
67
67
"sub not found in dig sub" . to_owned ( ) ,
68
68
) ) ?;
@@ -75,11 +75,10 @@ impl TabryConf {
75
75
pub fn find_in_subs < ' a > (
76
76
& ' a self ,
77
77
subs : & ' a [ TabrySub ] ,
78
- includes : & ' a Vec < String > ,
79
78
name : & String ,
80
79
check_aliases : bool ,
81
80
) -> Result < Option < & TabryConcreteSub > , TabryConfError > {
82
- let concrete_subs: Vec < & TabryConcreteSub > = self . flatten_subs ( subs, includes ) ?;
81
+ let concrete_subs: Vec < & TabryConcreteSub > = self . flatten_subs ( subs) ?;
83
82
84
83
for sub in concrete_subs {
85
84
let sub_name = Self :: unwrap_sub_name ( sub) ?;
@@ -116,16 +115,15 @@ impl TabryConf {
116
115
pub fn flatten_subs < ' a > (
117
116
& ' a self ,
118
117
subs : & ' a [ TabrySub ] ,
119
- includes : & ' a Vec < String > ,
120
118
) -> Result < Vec < & TabryConcreteSub > , TabryConfError > {
121
- let mut vecofvecs = subs
119
+ let vecofvecs = subs
122
120
. iter ( )
123
121
. map ( |sub| match sub {
124
122
TabrySub :: TabryIncludeSub { include } => {
125
123
// Lookup include, which may return an error
126
124
let inc = self . get_arg_include ( include) ?;
127
125
// Flatten the include's subs recursively (which may return an error)
128
- self . flatten_subs ( & inc. subs , & inc . includes )
126
+ self . flatten_subs ( & inc. subs )
129
127
}
130
128
TabrySub :: TabryConcreteSub ( s) =>
131
129
// This is a concrete sub, add it
@@ -135,15 +133,6 @@ impl TabryConf {
135
133
} )
136
134
. collect :: < Result < Vec < _ > , _ > > ( ) ?;
137
135
138
- vecofvecs. extend (
139
- includes. iter ( ) . map ( |include| {
140
- // Lookup include, which may return an error
141
- let inc = self . get_arg_include ( include) ?;
142
- // Flatten the include's subs recursively (which may return an error)
143
- self . flatten_subs ( & inc. subs , & inc. includes )
144
- } ) . collect :: < Result < Vec < _ > , _ > > ( ) ?,
145
- ) ;
146
-
147
136
// collect() will return an error if there were one, so now we just have flatten the
148
137
// vectors
149
138
Ok ( vecofvecs. into_iter ( ) . flatten ( ) . collect :: < Vec < _ > > ( ) )
@@ -154,47 +143,31 @@ impl TabryConf {
154
143
pub fn expand_flags < ' a > (
155
144
& ' a self ,
156
145
flags : & ' a [ TabryFlag ] ,
157
- includes : & ' a [ String ] ,
158
146
) -> Box < dyn Iterator < Item = & TabryConcreteFlag > + ' a > {
159
147
let iter = flags. iter ( ) . flat_map ( |flag| match flag {
160
148
TabryFlag :: TabryIncludeFlag { include } => {
161
149
// TODO: bubble up error instead of unwrap (use get_arg_include)
162
150
let include = self . arg_includes . get ( include) . unwrap ( ) ;
163
- self . expand_flags ( & include. flags , & include . includes )
151
+ self . expand_flags ( & include. flags )
164
152
}
165
153
TabryFlag :: TabryConcreteFlag ( concrete_flag) => Box :: new ( std:: iter:: once ( concrete_flag) ) ,
166
154
} ) ;
167
- let iter = iter. chain (
168
- includes. iter ( ) . flat_map ( move |include| {
169
- // TODO: bubble up error instead of unwrap
170
- let inc = self . arg_includes . get ( include) . unwrap ( ) ;
171
- self . expand_flags ( & inc. flags , & inc. includes )
172
- } ) ,
173
- ) ;
174
-
175
155
Box :: new ( iter)
176
156
}
177
157
178
158
// TODO: this is an exact copy of the the above expand_flags()
179
159
pub fn expand_args < ' a > (
180
160
& ' a self ,
181
161
args : & ' a [ TabryArg ] ,
182
- includes : & ' a [ String ] ,
183
162
) -> Box < dyn Iterator < Item = & TabryConcreteArg > + ' a > {
184
163
let iter = args. iter ( ) . flat_map ( |arg| match arg {
185
164
TabryArg :: TabryIncludeArg { include } => {
186
165
// TODO: bubble up error instead of unwrap (use get_arg_include)
187
166
let include = self . arg_includes . get ( include) . unwrap ( ) ;
188
- self . expand_args ( & include. args , & include . includes )
167
+ self . expand_args ( & include. args )
189
168
}
190
169
TabryArg :: TabryConcreteArg ( concrete_arg) => Box :: new ( std:: iter:: once ( concrete_arg) ) ,
191
170
} ) ;
192
- let iter = iter. chain (
193
- includes. iter ( ) . flat_map ( move |include| {
194
- let inc = self . arg_includes . get ( include) . unwrap ( ) ;
195
- self . expand_args ( & inc. args , & inc. includes )
196
- } ) ,
197
- ) ;
198
171
Box :: new ( iter)
199
172
}
200
173
}
0 commit comments