Skip to content

Commit a962804

Browse files
committed
use eprintln macro
1 parent a76135e commit a962804

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const AUTHOR: &str = "(c) Jens Getreu, 2016-2018";
4646

4747
/// This function spawns and defines the behaviour of the _merger-thread_ who
4848
/// collects and prints the results produced by the worker threads.
49-
fn main2() -> Result<(), Box<std::io::Error>> {
49+
fn run() -> Result<(), Box<std::io::Error>> {
5050
if ARGS.flag_list_encodings {
5151
let list = all::encodings()
5252
.iter()
@@ -109,13 +109,7 @@ fn main2() -> Result<(), Box<std::io::Error>> {
109109
} else {
110110
for filename in ARGS.arg_FILE.iter() {
111111
if let Err(e) = process_input(Some(&filename), &mut sc) {
112-
writeln!(
113-
&mut std::io::stderr(),
114-
"Warning: `{}` while scanning file `{}`.",
115-
e,
116-
filename
117-
)
118-
.unwrap();
112+
eprintln!("Warning: `{}` while scanning file `{}`.", e, filename);
119113
};
120114
}
121115
};
@@ -126,8 +120,8 @@ fn main2() -> Result<(), Box<std::io::Error>> {
126120
}
127121

128122
fn main() {
129-
if let Err(e) = main2() {
130-
writeln!(&mut std::io::stderr(), "Error: `{}`.", e).unwrap();
123+
if let Err(e) = run() {
124+
eprintln!("Error: `{}`.", e);
131125
process::exit(1);
132126
}
133127
}

src/mission.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::cmp;
1313
use std::cmp::{Eq, Ord};
1414
use std::error;
1515
use std::fmt;
16-
use std::io::prelude::*;
1716
use std::num;
1817
use std::process;
1918
use std::str;
@@ -223,13 +222,7 @@ impl Missions {
223222
match Self::parse_enc_opt(&enc_opt, flag_bytes.unwrap()) {
224223
Ok(r) => r,
225224
Err(e) => {
226-
writeln!(
227-
&mut std::io::stderr(),
228-
"Error: {} while parsing `{}`.",
229-
e,
230-
&enc_opt
231-
)
232-
.unwrap();
225+
eprintln!("Error: {} while parsing `{}`.", e, &enc_opt);
233226
process::exit(1);
234227
}
235228
};
@@ -269,12 +262,10 @@ impl Missions {
269262
enable_filter: control_char_filtering || unicode_filtering,
270263
},
271264
None => {
272-
writeln!(
273-
&mut std::io::stderr(),
265+
eprintln!(
274266
"Error: Invalid input encoding name '{}', try option -l.",
275267
enc_name
276-
)
277-
.unwrap();
268+
);
278269
process::exit(1);
279270
}
280271
});
@@ -309,14 +300,12 @@ impl Missions {
309300
if !((u_lower == 0) && (u_upper == std::char::MAX as u32))
310301
&& ((u_lower != u_lower_ext) || (u_upper != u_upper_ext))
311302
{
312-
writeln!(
313-
&mut std::io::stderr(),
303+
eprintln!(
314304
"Warning: range in `{}` extended to range `U+{:x}..U+{:x}`.",
315305
enc_opt,
316306
u_lower_ext,
317307
u_upper_ext
318-
)
319-
.unwrap();
308+
);
320309
}
321310

322311
let u_and_result = u_lower_ext;

0 commit comments

Comments
 (0)