Skip to content

Commit

Permalink
Fix clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed May 22, 2022
1 parent 0ae8916 commit 1fb5263
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
12 changes: 2 additions & 10 deletions src/bin/hexyl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,16 +612,8 @@ fn test_process_sign() {
fn test_parse_as_hex() {
assert_eq!(try_parse_as_hex_number("73"), None);
assert_eq!(try_parse_as_hex_number("0x1337"), Some(Ok(0x1337)));
assert!(if let Some(Err(_)) = try_parse_as_hex_number("0xnope") {
true
} else {
false
});
assert!(if let Some(Err(_)) = try_parse_as_hex_number("0x-1") {
true
} else {
false
});
assert!(matches!(try_parse_as_hex_number("0xnope"), Some(Err(_))));
assert!(matches!(try_parse_as_hex_number("0x-1"), Some(Err(_))));
}

#[test]
Expand Down
36 changes: 9 additions & 27 deletions src/squeezer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,15 @@ mod tests {
SqueezeAction::Delete, // delete reoccurring line
];

let mut line = 0;
let mut idx = 1;
for z in v.chunks(LSIZE_USIZE) {
for (line, z) in v.chunks(LSIZE_USIZE).enumerate() {
for i in z {
s.process(*i, idx);
idx += 1;
}
let action = s.action();
s.advance();
assert_eq!(action, exp[line]);
line += 1;
}
}

Expand All @@ -158,16 +156,14 @@ mod tests {
SqueezeAction::Ignore, // last line only 12 bytes, print it
];

let mut line = 0;
let mut idx = 1;
for z in v.chunks(LSIZE_USIZE) {
for (line, z) in v.chunks(LSIZE_USIZE).enumerate() {
for i in z {
s.process(*i, idx);
idx += 1;
}
assert_eq!(s.action(), exp[line]);
s.advance();
line += 1;
}
}

Expand All @@ -190,17 +186,15 @@ mod tests {
SqueezeAction::Ignore, // different
];

let mut line = 0;
let mut idx = 1;
for z in v.chunks(LSIZE_USIZE) {
for (line, z) in v.chunks(LSIZE_USIZE).enumerate() {
for i in z {
s.process(*i, idx);
idx += 1;
}
let action = s.action();
assert_eq!(action, exp[line]);
s.advance();
line += 1;
}
}

Expand All @@ -223,17 +217,15 @@ mod tests {
SqueezeAction::Ignore, // different lines, print again
];

let mut line = 0;
let mut idx = 1;
for z in v.chunks(LSIZE_USIZE) {
for (line, z) in v.chunks(LSIZE_USIZE).enumerate() {
for i in z {
s.process(*i, idx);
idx += 1;
}
let action = s.action();
s.advance();
assert_eq!(action, exp[line]);
line += 1;
}
}

Expand All @@ -255,17 +247,15 @@ mod tests {
SqueezeAction::Ignore, // print squeeze symbol
];

let mut line = 0;
let mut idx = 1;
for z in v.chunks(LSIZE_USIZE) {
for (line, z) in v.chunks(LSIZE_USIZE).enumerate() {
for i in z {
s.process(*i, idx);
idx += 1;
}
let action = s.action();
s.advance();
assert_eq!(action, exp[line]);
line += 1;
}
}

Expand All @@ -291,17 +281,15 @@ mod tests {
SqueezeAction::Ignore, // print squeeze symbol
];

let mut line = 0;
let mut idx = 1;
for z in v.chunks(LSIZE_USIZE) {
for (line, z) in v.chunks(LSIZE_USIZE).enumerate() {
for i in z {
s.process(*i, idx);
idx += 1;
}
let action = s.action();
s.advance();
assert_eq!(action, exp[line]);
line += 1;
}
}

Expand Down Expand Up @@ -341,17 +329,15 @@ mod tests {
SqueezeAction::Ignore,
];

let mut line = 0;
let mut idx = 1;
for z in v.chunks(LSIZE_USIZE) {
for (line, z) in v.chunks(LSIZE_USIZE).enumerate() {
for i in z {
s.process(*i, idx);
idx += 1;
}
let action = s.action();
s.advance();
assert_eq!(action, exp[line]);
line += 1;
}
}

Expand All @@ -377,16 +363,14 @@ mod tests {
SqueezeAction::Print, // print '*' char
];

let mut line = 0;
let mut idx = 1;
for z in v.chunks(LSIZE_USIZE) {
for (line, z) in v.chunks(LSIZE_USIZE).enumerate() {
for i in z {
s.process(*i, idx);
idx += 1;
}
assert_eq!(s.action(), exp[line]);
s.advance();
line += 1;
}
}

Expand All @@ -410,16 +394,14 @@ mod tests {
SqueezeAction::Ignore, // print as is
];

let mut line = 0;
let mut idx = 1;
for z in v.chunks(LSIZE_USIZE) {
for (line, z) in v.chunks(LSIZE_USIZE).enumerate() {
for i in z {
s.process(*i, idx);
idx += 1;
}
assert_eq!(s.action(), exp[line]);
s.advance();
line += 1;
}
}
}

0 comments on commit 1fb5263

Please sign in to comment.