Skip to content

Commit 73cfd05

Browse files
committed
Minor updates
1 parent 37e9ef6 commit 73cfd05

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

src/main.rs

+20-22
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct Opt {
186186
terminal_width: Option<NonZeroU64>,
187187

188188
/// Print a table showing how different types of bytes are colored.
189-
#[arg(short('t'), long)]
189+
#[arg(long)]
190190
print_color_table: bool,
191191
}
192192

@@ -429,10 +429,9 @@ fn run() -> Result<()> {
429429

430430
let character_table = opt.character_table;
431431

432-
let stdout = io::stdout();
433-
let mut stdout_lock = BufWriter::new(stdout.lock());
432+
let mut stdout = BufWriter::new(io::stdout().lock());
434433

435-
let mut printer = PrinterBuilder::new(&mut stdout_lock)
434+
let mut printer = PrinterBuilder::new(&mut stdout)
436435
.show_color(show_color)
437436
.show_char_panel(show_char_panel)
438437
.show_position_panel(show_position_panel)
@@ -489,38 +488,37 @@ impl From<NonNegativeI64> for u64 {
489488
}
490489

491490
fn print_color_table() -> io::Result<()> {
492-
let stdout = io::stdout();
493-
let mut stdout_lock = BufWriter::new(stdout.lock());
491+
let mut stdout = BufWriter::new(io::stdout().lock());
494492

495-
writeln!(stdout_lock, "hexyl color reference:\n")?;
493+
writeln!(stdout, "hexyl color reference:\n")?;
496494

497495
// NULL bytes
498-
stdout_lock.write_all(COLOR_NULL)?;
499-
writeln!(stdout_lock, "⋄ NULL bytes (0x00)")?;
500-
stdout_lock.write_all(COLOR_RESET)?;
496+
stdout.write_all(COLOR_NULL)?;
497+
writeln!(stdout, "⋄ NULL bytes (0x00)")?;
498+
stdout.write_all(COLOR_RESET)?;
501499

502500
// ASCII printable
503-
stdout_lock.write_all(COLOR_ASCII_PRINTABLE)?;
504-
writeln!(stdout_lock, "a ASCII printable characters (0x20 - 0x7E)")?;
505-
stdout_lock.write_all(COLOR_RESET)?;
501+
stdout.write_all(COLOR_ASCII_PRINTABLE)?;
502+
writeln!(stdout, "a ASCII printable characters (0x20 - 0x7E)")?;
503+
stdout.write_all(COLOR_RESET)?;
506504

507505
// ASCII whitespace
508-
stdout_lock.write_all(COLOR_ASCII_WHITESPACE)?;
509-
writeln!(stdout_lock, "_ ASCII whitespace (0x09 - 0x0D, 0x20)")?;
510-
stdout_lock.write_all(COLOR_RESET)?;
506+
stdout.write_all(COLOR_ASCII_WHITESPACE)?;
507+
writeln!(stdout, "_ ASCII whitespace (0x09 - 0x0D, 0x20)")?;
508+
stdout.write_all(COLOR_RESET)?;
511509

512510
// ASCII other
513-
stdout_lock.write_all(COLOR_ASCII_OTHER)?;
511+
stdout.write_all(COLOR_ASCII_OTHER)?;
514512
writeln!(
515-
stdout_lock,
513+
stdout,
516514
"• ASCII control characters (except NULL and whitespace)"
517515
)?;
518-
stdout_lock.write_all(COLOR_RESET)?;
516+
stdout.write_all(COLOR_RESET)?;
519517

520518
// Non-ASCII
521-
stdout_lock.write_all(COLOR_NONASCII)?;
522-
writeln!(stdout_lock, "× Non-ASCII bytes (0x80 - 0xFF)")?;
523-
stdout_lock.write_all(COLOR_RESET)?;
519+
stdout.write_all(COLOR_NONASCII)?;
520+
writeln!(stdout, "× Non-ASCII bytes (0x80 - 0xFF)")?;
521+
stdout.write_all(COLOR_RESET)?;
524522

525523
Ok(())
526524
}

0 commit comments

Comments
 (0)