Skip to content

Commit d6cac97

Browse files
authored
Merge pull request #137 from samueltardieu/style-fixes
Style fixes
2 parents c5b6937 + d4df77a commit d6cac97

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/lib.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Result<Paths, PatternE
208208
}
209209

210210
// 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)?;
214212

215213
let mut components = Path::new(pattern).components().peekable();
216214
loop {
@@ -391,7 +389,7 @@ impl Iterator for Paths {
391389
if let Some(scope) = self.scope.take() {
392390
if !self.dir_patterns.is_empty() {
393391
// 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);
395393

396394
fill_todo(&mut self.todo, &self.dir_patterns, 0, &scope, self.options);
397395
}
@@ -409,7 +407,7 @@ impl Iterator for Paths {
409407

410408
// idx -1: was already checked by fill_todo, maybe path was '.' or
411409
// '..' that we can't match here because of normalization.
412-
if idx == !0 as usize {
410+
if idx == std::usize::MAX {
413411
if self.require_dir && !path.is_directory {
414412
continue;
415413
}
@@ -843,8 +841,8 @@ impl Pattern {
843841
false
844842
}
845843
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),
848846
Char(c2) => chars_eq(c, c2, options.case_sensitive),
849847
AnySequence | AnyRecursiveSequence => unreachable!(),
850848
} {
@@ -892,7 +890,7 @@ fn fill_todo(
892890
// We know it's good, so don't make the iterator match this path
893891
// against the pattern again. In particular, it can't match
894892
// . 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)));
896894
} else {
897895
fill_todo(todo, patterns, idx + 1, &next_path, options);
898896
}
@@ -941,7 +939,7 @@ fn fill_todo(
941939
Ok(mut children) => {
942940
if options.require_literal_leading_dot {
943941
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('.'));
945943
}
946944
children.sort_by(|p1, p2| p2.file_name().cmp(&p1.file_name()));
947945
todo.extend(children.into_iter().map(|x| Ok((x, idx))));
@@ -1490,12 +1488,12 @@ mod test {
14901488
fn test_matches_path() {
14911489
// on windows, (Path::new("a/b").as_str().unwrap() == "a\\b"), so this
14921490
// 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")));
14941492
}
14951493

14961494
#[test]
14971495
fn test_path_join() {
1498-
let pattern = Path::new("one").join(&Path::new("**/*.rs"));
1496+
let pattern = Path::new("one").join(Path::new("**/*.rs"));
14991497
assert!(Pattern::new(pattern.to_str().unwrap()).is_ok());
15001498
}
15011499
}

0 commit comments

Comments
 (0)