Skip to content

Commit feb0e72

Browse files
swolchokfacebook-github-bot
authored andcommitted
s/writeln!(::std::io::stderr/eprintln!(/
Summary: This seems much tidier and doesn't require a trailing `expect()` call. Reviewed By: adamjernst Differential Revision: D15994102 fbshipit-source-id: 9736ebe7ef80813ffe4ee0058aba982982b46dd4
1 parent e903f1b commit feb0e72

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/main.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ fn get_file_set(matches: &clap::ArgMatches) -> Option<FileSet> {
6868
}
6969

7070
fn notify_fast_mode() {
71-
writeln!(
72-
::std::io::stderr(),
73-
"Fast mode activated. Sit back, relax, and enjoy the brief flight."
74-
)
75-
.expect("error writing to stderr");
71+
eprintln!("Fast mode activated. Sit back, relax, and enjoy the brief flight.");
7672
}
7773

7874
fn slurp(path: &Path) -> Result<String> {
@@ -468,8 +464,7 @@ impl Fastmod {
468464
// interactive input from a human, so we simply can't use
469465
// *that* much memory in modern terms.
470466
for error in errors {
471-
writeln!(::std::io::stderr(), "{}", display_warning(&error))
472-
.expect("error writing to stderr");
467+
eprintln!("{}", display_warning(&error));
473468
}
474469
});
475470

@@ -571,8 +566,7 @@ impl Fastmod {
571566
let changed_files = changed_files_inner.clone();
572567
Box::new(move |result| {
573568
if let Err(error) = result {
574-
writeln!(::std::io::stderr(), "Warning: {}", &error)
575-
.expect("error writing to stderr");
569+
eprintln!("Warning: {}", &error);
576570
return WalkState::Continue;
577571
}
578572
let dirent = result.unwrap();
@@ -591,8 +585,7 @@ impl Fastmod {
591585
}
592586
let slurped = slurp(path);
593587
if let Err(error) = slurped {
594-
writeln!(::std::io::stderr(), "{}", display_warning(&error))
595-
.expect("error writing to stderr");
588+
eprintln!("{}", display_warning(&error));
596589
return WalkState::Continue;
597590
}
598591
let contents = slurped.expect("checked for error above");
@@ -604,8 +597,7 @@ impl Fastmod {
604597
changed_files.push(path.to_owned())
605598
}
606599
}
607-
Err(error) => writeln!(::std::io::stderr(), "{}", display_warning(&error))
608-
.expect("error writing to stderr"),
600+
Err(error) => eprintln!("{}", display_warning(&error)),
609601
}
610602
}
611603
WalkState::Continue
@@ -784,7 +776,7 @@ compatibility with the original codemod.",
784776

785777
fn main() {
786778
if let Err(e) = fastmod() {
787-
write!(::std::io::stderr(), "{:?}", e).expect("Couldn't write to stderr");
779+
eprint!("{:?}", e);
788780
}
789781
}
790782

0 commit comments

Comments
 (0)