@@ -208,9 +208,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Result<Paths, PatternE
208
208
}
209
209
210
210
// make sure that the pattern is valid first, else early return with error
211
- if let Err ( err) = Pattern :: new ( pattern) {
212
- return Err ( err) ;
213
- }
211
+ let _ = Pattern :: new ( pattern) ?;
214
212
215
213
let mut components = Path :: new ( pattern) . components ( ) . peekable ( ) ;
216
214
loop {
@@ -391,7 +389,7 @@ impl Iterator for Paths {
391
389
if let Some ( scope) = self . scope . take ( ) {
392
390
if !self . dir_patterns . is_empty ( ) {
393
391
// Shouldn't happen, but we're using -1 as a special index.
394
- assert ! ( self . dir_patterns. len( ) < ! 0 as usize ) ;
392
+ assert ! ( self . dir_patterns. len( ) < std :: usize :: MAX ) ;
395
393
396
394
fill_todo ( & mut self . todo , & self . dir_patterns , 0 , & scope, self . options ) ;
397
395
}
@@ -409,7 +407,7 @@ impl Iterator for Paths {
409
407
410
408
// idx -1: was already checked by fill_todo, maybe path was '.' or
411
409
// '..' that we can't match here because of normalization.
412
- if idx == ! 0 as usize {
410
+ if idx == std :: usize:: MAX {
413
411
if self . require_dir && !path. is_directory {
414
412
continue ;
415
413
}
@@ -843,8 +841,8 @@ impl Pattern {
843
841
false
844
842
}
845
843
AnyChar => true ,
846
- AnyWithin ( ref specifiers) => in_char_specifiers ( & specifiers, c, options) ,
847
- AnyExcept ( ref specifiers) => !in_char_specifiers ( & specifiers, c, options) ,
844
+ AnyWithin ( ref specifiers) => in_char_specifiers ( specifiers, c, options) ,
845
+ AnyExcept ( ref specifiers) => !in_char_specifiers ( specifiers, c, options) ,
848
846
Char ( c2) => chars_eq ( c, c2, options. case_sensitive ) ,
849
847
AnySequence | AnyRecursiveSequence => unreachable ! ( ) ,
850
848
} {
@@ -892,7 +890,7 @@ fn fill_todo(
892
890
// We know it's good, so don't make the iterator match this path
893
891
// against the pattern again. In particular, it can't match
894
892
// . or .. globs since these never show up as path components.
895
- todo. push ( Ok ( ( next_path, ! 0 as usize ) ) ) ;
893
+ todo. push ( Ok ( ( next_path, std :: usize:: MAX ) ) ) ;
896
894
} else {
897
895
fill_todo ( todo, patterns, idx + 1 , & next_path, options) ;
898
896
}
@@ -941,7 +939,7 @@ fn fill_todo(
941
939
Ok ( mut children) => {
942
940
if options. require_literal_leading_dot {
943
941
children
944
- . retain ( |x| !x. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . starts_with ( "." ) ) ;
942
+ . retain ( |x| !x. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . starts_with ( '.' ) ) ;
945
943
}
946
944
children. sort_by ( |p1, p2| p2. file_name ( ) . cmp ( & p1. file_name ( ) ) ) ;
947
945
todo. extend ( children. into_iter ( ) . map ( |x| Ok ( ( x, idx) ) ) ) ;
@@ -1490,12 +1488,12 @@ mod test {
1490
1488
fn test_matches_path ( ) {
1491
1489
// on windows, (Path::new("a/b").as_str().unwrap() == "a\\b"), so this
1492
1490
// tests that / and \ are considered equivalent on windows
1493
- assert ! ( Pattern :: new( "a/b" ) . unwrap( ) . matches_path( & Path :: new( "a/b" ) ) ) ;
1491
+ assert ! ( Pattern :: new( "a/b" ) . unwrap( ) . matches_path( Path :: new( "a/b" ) ) ) ;
1494
1492
}
1495
1493
1496
1494
#[ test]
1497
1495
fn test_path_join ( ) {
1498
- let pattern = Path :: new ( "one" ) . join ( & Path :: new ( "**/*.rs" ) ) ;
1496
+ let pattern = Path :: new ( "one" ) . join ( Path :: new ( "**/*.rs" ) ) ;
1499
1497
assert ! ( Pattern :: new( pattern. to_str( ) . unwrap( ) ) . is_ok( ) ) ;
1500
1498
}
1501
1499
}
0 commit comments