Skip to content

Commit ada13c1

Browse files
committed
wc: Fix clippy::bool_comparison
1 parent a00830a commit ada13c1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

text/wc.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,8 @@ const BYTE_TABLE: [bool; 256] = create_table();
7373
fn build_display_str(args: &Args, count: &CountInfo, filename: &OsStr) -> String {
7474
let mut output = String::with_capacity(filename.len() + (3 * 10));
7575

76-
let multi_file = args.files.len() > 1;
77-
let only_lines = (args.words == false) && (args.bytes == false) && (args.chars == false);
78-
let only_words = (args.lines == false) && (args.bytes == false) && (args.chars == false);
79-
let only_bytechars = (args.lines == false) && (args.words == false);
80-
8176
if args.lines {
77+
let only_lines = !args.words && !args.bytes && !args.chars;
8278
let numstr = match only_lines {
8379
true => format!("{}", count.nl),
8480
false => format!("{:>8}", count.nl),
@@ -89,6 +85,7 @@ fn build_display_str(args: &Args, count: &CountInfo, filename: &OsStr) -> String
8985
if !output.is_empty() {
9086
output.push(' ');
9187
}
88+
let only_words = !args.lines && !args.bytes && !args.chars;
9289
let numstr = match only_words {
9390
true => format!("{}", count.words),
9491
false => format!("{:>8}", count.words),
@@ -99,13 +96,15 @@ fn build_display_str(args: &Args, count: &CountInfo, filename: &OsStr) -> String
9996
if !output.is_empty() {
10097
output.push(' ');
10198
}
99+
let only_bytechars = !args.lines && !args.words;
102100
let numstr = match only_bytechars {
103101
true => format!("{}", count.chars),
104102
false => format!("{:>8}", count.chars),
105103
};
106104
output.push_str(&numstr);
107105
}
108106

107+
let multi_file = args.files.len() > 1;
109108
if multi_file {
110109
output.push(' ');
111110

0 commit comments

Comments
 (0)