Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions text/wc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,8 @@ const BYTE_TABLE: [bool; 256] = create_table();
fn build_display_str(args: &Args, count: &CountInfo, filename: &OsStr) -> String {
let mut output = String::with_capacity(filename.len() + (3 * 10));

let multi_file = args.files.len() > 1;
let only_lines = (args.words == false) && (args.bytes == false) && (args.chars == false);
let only_words = (args.lines == false) && (args.bytes == false) && (args.chars == false);
let only_bytechars = (args.lines == false) && (args.words == false);

if args.lines {
let only_lines = !args.words && !args.bytes && !args.chars;
let numstr = match only_lines {
true => format!("{}", count.nl),
false => format!("{:>8}", count.nl),
Expand All @@ -89,6 +85,7 @@ fn build_display_str(args: &Args, count: &CountInfo, filename: &OsStr) -> String
if !output.is_empty() {
output.push(' ');
}
let only_words = !args.lines && !args.bytes && !args.chars;
let numstr = match only_words {
true => format!("{}", count.words),
false => format!("{:>8}", count.words),
Expand All @@ -99,13 +96,15 @@ fn build_display_str(args: &Args, count: &CountInfo, filename: &OsStr) -> String
if !output.is_empty() {
output.push(' ');
}
let only_bytechars = !args.lines && !args.words;
let numstr = match only_bytechars {
true => format!("{}", count.chars),
false => format!("{:>8}", count.chars),
};
output.push_str(&numstr);
}

let multi_file = args.files.len() > 1;
if multi_file {
output.push(' ');

Expand Down