Skip to content

Commit 0d6f408

Browse files
committed
use !is_empty rather than len > 0, for _ in &_ rather than for _ in _.iter()
1 parent 4223d07 commit 0d6f408

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl Iterator for Paths {
325325
// failing to fill the buffer is an iteration error construction of the
326326
// iterator (i.e. glob()) only fails if it fails to compile the Pattern
327327
if let Some(scope) = self.scope.take() {
328-
if self.dir_patterns.len() > 0 {
328+
if !self.dir_patterns.is_empty() {
329329
// Shouldn't happen, but we're using -1 as a special index.
330330
assert!(self.dir_patterns.len() < !0 as usize);
331331

@@ -790,7 +790,7 @@ fn fill_todo(todo: &mut Vec<Result<(PathBuf, usize), GlobError>>,
790790
// convert a pattern that's just many Char(_) to a string
791791
fn pattern_as_str(pattern: &Pattern) -> Option<String> {
792792
let mut s = String::new();
793-
for token in pattern.tokens.iter() {
793+
for token in &pattern.tokens {
794794
match *token {
795795
Char(c) => s.push(c),
796796
_ => return None,
@@ -854,8 +854,8 @@ fn fill_todo(todo: &mut Vec<Result<(PathBuf, usize), GlobError>>,
854854
// requires that the pattern has a leading dot, even if the
855855
// `MatchOptions` field `require_literal_leading_dot` is not
856856
// set.
857-
if pattern.tokens.len() > 0 && pattern.tokens[0] == Char('.') {
858-
for &special in [".", ".."].iter() {
857+
if !pattern.tokens.is_empty() && pattern.tokens[0] == Char('.') {
858+
for &special in &[".", ".."] {
859859
if pattern.matches_with(special, options) {
860860
add(todo, path.join(special));
861861
}

0 commit comments

Comments
 (0)