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> {
167167/// Paths are yielded in alphabetical order.
168168pub fn glob_with ( pattern : & str , options : & MatchOptions )
169169 -> 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-
173170 #[ cfg( windows) ]
174171 fn check_windows_verbatim ( p : & Path ) -> bool {
175172 use std:: path:: Prefix ;
@@ -193,6 +190,12 @@ pub fn glob_with(pattern: &str, options: &MatchOptions)
193190 p. to_path_buf ( )
194191 }
195192
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+
196199 let mut components = Path :: new ( pattern) . components ( ) . peekable ( ) ;
197200 loop {
198201 match components. peek ( ) {
@@ -232,8 +235,7 @@ pub fn glob_with(pattern: &str, options: &MatchOptions)
232235 . split_terminator ( path:: is_separator) ;
233236
234237 for component in components {
235- let compiled = try!( Pattern :: new ( component) ) ;
236- dir_patterns. push ( compiled) ;
238+ dir_patterns. push ( Pattern :: new ( component) ?) ;
237239 }
238240
239241 if root_len == pattern. len ( ) {
You can’t perform that action at this time.
0 commit comments