Skip to content

Commit 1b5bc8c

Browse files
committed
Fix exit_code example: Remove indirection, return Result from main()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
1 parent e374375 commit 1b5bc8c

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

examples/exit_code.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rexpect::spawn;
88
/// cat exited with code 0, all good!
99
/// cat exited with code 1
1010
/// Output (stdout and stderr): cat: /this/does/not/exist: No such file or directory
11-
fn exit_code_fun() -> Result<(), Error> {
11+
fn main() -> Result<(), Error> {
1212
let p = spawn("cat /etc/passwd", Some(2000))?;
1313
match p.process.wait() {
1414
Ok(wait::WaitStatus::Exited(_, 0)) => println!("cat exited with code 0, all good!"),
@@ -29,7 +29,3 @@ fn exit_code_fun() -> Result<(), Error> {
2929

3030
Ok(())
3131
}
32-
33-
fn main() {
34-
exit_code_fun().unwrap_or_else(|e| panic!("cat function failed with {}", e));
35-
}

0 commit comments

Comments
 (0)