Skip to content

Commit 744947c

Browse files
make main() alone handle process exit status
1 parent 217a0c8 commit 744947c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

examples/write_dir.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ enum CompressionMethod {
3030
Zstd,
3131
}
3232

33-
fn main() {
34-
std::process::exit(real_main());
35-
}
36-
37-
fn real_main() -> i32 {
33+
fn main() -> ! {
3834
let args = Args::parse();
3935
let src_dir = &args.source;
4036
let dst_file = &args.destination;
@@ -70,11 +66,15 @@ fn real_main() -> i32 {
7066
},
7167
};
7268
match doit(src_dir, dst_file, method) {
73-
Ok(_) => println!("done: {src_dir:?} written to {dst_file:?}"),
74-
Err(e) => eprintln!("Error: {e:?}"),
69+
Ok(_) => {
70+
println!("done: {src_dir:?} written to {dst_file:?}");
71+
std::process::exit(0);
72+
}
73+
Err(e) => {
74+
eprintln!("Error: {e:?}");
75+
std::process::abort();
76+
}
7577
}
76-
77-
0
7878
}
7979

8080
fn zip_dir<T>(

0 commit comments

Comments
 (0)