@@ -149,7 +149,7 @@ pub struct Paths {
149
149
/// ```
150
150
/// Paths are yielded in alphabetical order.
151
151
pub fn glob ( pattern : & str ) -> Result < Paths , PatternError > {
152
- glob_with ( pattern, & MatchOptions :: new ( ) )
152
+ glob_with ( pattern, MatchOptions :: new ( ) )
153
153
}
154
154
155
155
/// Return an iterator that produces all the `Path`s that match the given
@@ -165,7 +165,7 @@ pub fn glob(pattern: &str) -> Result<Paths, PatternError> {
165
165
/// passed to this function.
166
166
///
167
167
/// Paths are yielded in alphabetical order.
168
- pub fn glob_with ( pattern : & str , options : & MatchOptions )
168
+ pub fn glob_with ( pattern : & str , options : MatchOptions )
169
169
-> Result < Paths , PatternError > {
170
170
#[ cfg( windows) ]
171
171
fn check_windows_verbatim ( p : & Path ) -> bool {
@@ -222,13 +222,13 @@ pub fn glob_with(pattern: &str, options: &MatchOptions)
222
222
return Ok ( Paths {
223
223
dir_patterns : Vec :: new ( ) ,
224
224
require_dir : false ,
225
- options : options . clone ( ) ,
225
+ options,
226
226
todo : Vec :: new ( ) ,
227
227
scope : None ,
228
228
} ) ;
229
229
}
230
230
231
- let scope = root. map ( to_scope ) . unwrap_or_else ( || PathBuf :: from ( "." ) ) ;
231
+ let scope = root. map_or_else ( || PathBuf :: from ( "." ) , to_scope ) ;
232
232
233
233
let mut dir_patterns = Vec :: new ( ) ;
234
234
let components = pattern[ cmp:: min ( root_len, pattern. len ( ) ) ..]
@@ -253,7 +253,7 @@ pub fn glob_with(pattern: &str, options: &MatchOptions)
253
253
Ok ( Paths {
254
254
dir_patterns,
255
255
require_dir,
256
- options : options . clone ( ) ,
256
+ options,
257
257
todo,
258
258
scope : Some ( scope) ,
259
259
} )
@@ -333,7 +333,7 @@ impl Iterator for Paths {
333
333
& self . dir_patterns ,
334
334
0 ,
335
335
& scope,
336
- & self . options ) ;
336
+ self . options ) ;
337
337
}
338
338
}
339
339
@@ -373,7 +373,7 @@ impl Iterator for Paths {
373
373
& self . dir_patterns ,
374
374
next,
375
375
& path,
376
- & self . options ) ;
376
+ self . options ) ;
377
377
378
378
if next == self . dir_patterns . len ( ) - 1 {
379
379
// pattern ends in recursive pattern, so return this
@@ -402,7 +402,7 @@ impl Iterator for Paths {
402
402
None => continue ,
403
403
Some ( x) => x
404
404
}
405
- } , & self . options ) {
405
+ } , self . options ) {
406
406
if idx == self . dir_patterns . len ( ) - 1 {
407
407
// it is not possible for a pattern to match a directory
408
408
// *AND* its children so we don't need to check the
@@ -413,7 +413,7 @@ impl Iterator for Paths {
413
413
}
414
414
} else {
415
415
fill_todo ( & mut self . todo , & self . dir_patterns ,
416
- idx + 1 , & path, & self . options ) ;
416
+ idx + 1 , & path, self . options ) ;
417
417
}
418
418
}
419
419
}
@@ -674,7 +674,7 @@ impl Pattern {
674
674
/// assert!(Pattern::new("d*g").unwrap().matches("doog"));
675
675
/// ```
676
676
pub fn matches ( & self , str : & str ) -> bool {
677
- self . matches_with ( str, & MatchOptions :: new ( ) )
677
+ self . matches_with ( str, MatchOptions :: new ( ) )
678
678
}
679
679
680
680
/// Return if the given `Path`, when converted to a `str`, matches this
@@ -686,13 +686,13 @@ impl Pattern {
686
686
687
687
/// Return if the given `str` matches this `Pattern` using the specified
688
688
/// match options.
689
- pub fn matches_with ( & self , str : & str , options : & MatchOptions ) -> bool {
689
+ pub fn matches_with ( & self , str : & str , options : MatchOptions ) -> bool {
690
690
self . matches_from ( true , str. chars ( ) , 0 , options) == Match
691
691
}
692
692
693
693
/// Return if the given `Path`, when converted to a `str`, matches this
694
694
/// `Pattern` using the specified match options.
695
- pub fn matches_path_with ( & self , path : & Path , options : & MatchOptions ) -> bool {
695
+ pub fn matches_path_with ( & self , path : & Path , options : MatchOptions ) -> bool {
696
696
// FIXME (#9639): This needs to handle non-utf8 paths
697
697
path. to_str ( ) . map_or ( false , |s| self . matches_with ( s, options) )
698
698
}
@@ -706,7 +706,7 @@ impl Pattern {
706
706
mut follows_separator : bool ,
707
707
mut file : std:: str:: Chars ,
708
708
i : usize ,
709
- options : & MatchOptions )
709
+ options : MatchOptions )
710
710
-> MatchResult {
711
711
712
712
for ( ti, token) in self . tokens [ i..] . iter ( ) . enumerate ( ) {
@@ -786,7 +786,7 @@ fn fill_todo(todo: &mut Vec<Result<(PathBuf, usize), GlobError>>,
786
786
patterns : & [ Pattern ] ,
787
787
idx : usize ,
788
788
path : & Path ,
789
- options : & MatchOptions ) {
789
+ options : MatchOptions ) {
790
790
// convert a pattern that's just many Char(_) to a string
791
791
fn pattern_as_str ( pattern : & Pattern ) -> Option < String > {
792
792
let mut s = String :: new ( ) ;
@@ -891,7 +891,7 @@ fn parse_char_specifiers(s: &[char]) -> Vec<CharSpecifier> {
891
891
cs
892
892
}
893
893
894
- fn in_char_specifiers ( specifiers : & [ CharSpecifier ] , c : char , options : & MatchOptions ) -> bool {
894
+ fn in_char_specifiers ( specifiers : & [ CharSpecifier ] , c : char , options : MatchOptions ) -> bool {
895
895
896
896
for & specifier in specifiers. iter ( ) {
897
897
match specifier {
0 commit comments