Skip to content

Commit 20ccfb3

Browse files
committed
Use write macro instead of print for stdout
1 parent 8e83b42 commit 20ccfb3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use converter::Converter;
1212
use reader::*;
1313
use std::error::Error;
1414
use std::io;
15+
use std::io::Write;
1516
use std::process;
1617

1718
struct Args<'a> {
@@ -31,6 +32,8 @@ fn run(args: Args) -> Result<bool, String> {
3132

3233
let c = Converter::new(tz, fmt)?;
3334
let stdin = io::stdin();
35+
let stdout = io::stdout();
36+
let mut writer = stdout.lock();
3437

3538
let reader = match filename {
3639
Some("-") => InputReader::new(Input::Stdin(&stdin)),
@@ -46,12 +49,12 @@ fn run(args: Args) -> Result<bool, String> {
4649
let mut has_next = true;
4750
let mut buf = String::new();
4851

49-
print!("{}", c.convert(reader.first_line()));
52+
write!(writer, "{}", c.convert(reader.first_line()));
5053

5154
while follow || has_next {
5255
match reader.read_line(&mut buf) {
5356
Ok(bytes) if bytes > 0 => {
54-
print!("{}", c.convert(&buf));
57+
write!(writer, "{}", c.convert(&buf));
5558
buf.clear();
5659
has_next = true;
5760
}

0 commit comments

Comments
 (0)