File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -167,9 +167,6 @@ pub fn glob(pattern: &str) -> Result<Paths, PatternError> {
167
167
/// Paths are yielded in alphabetical order.
168
168
pub fn glob_with ( pattern : & str , options : & MatchOptions )
169
169
-> Result < Paths , PatternError > {
170
- // make sure that the pattern is valid first, else early return with error
171
- let _compiled = try!( Pattern :: new ( pattern) ) ;
172
-
173
170
#[ cfg( windows) ]
174
171
fn check_windows_verbatim ( p : & Path ) -> bool {
175
172
use std:: path:: Prefix ;
@@ -193,6 +190,12 @@ pub fn glob_with(pattern: &str, options: &MatchOptions)
193
190
p. to_path_buf ( )
194
191
}
195
192
193
+ // make sure that the pattern is valid first, else early return with error
194
+ if let Err ( err) = Pattern :: new ( pattern) {
195
+ return Err ( err) ;
196
+ }
197
+
198
+
196
199
let mut components = Path :: new ( pattern) . components ( ) . peekable ( ) ;
197
200
loop {
198
201
match components. peek ( ) {
@@ -232,8 +235,7 @@ pub fn glob_with(pattern: &str, options: &MatchOptions)
232
235
. split_terminator ( path:: is_separator) ;
233
236
234
237
for component in components {
235
- let compiled = try!( Pattern :: new ( component) ) ;
236
- dir_patterns. push ( compiled) ;
238
+ dir_patterns. push ( Pattern :: new ( component) ?) ;
237
239
}
238
240
239
241
if root_len == pattern. len ( ) {
You can’t perform that action at this time.
0 commit comments