Return result of Command::execute directly from main #7

Closed
MarkusPettersson98 wants to merge 1 commit from main-returns-result into main

1 commit

Author SHA1 Message Date
Markus Pettersson
50485e7c3a Return result of Command::execute directly from main
Since `Result` implements
`Termination` (https://doc.rust-lang.org/std/process/trait.Termination.html),
the result of `Command::execute` can be returned from `main` directly.
If an `FF2MpvError` error would be propagated to `main`, it will be
printed using `eprintln` just as before, and the program will terminate
with an appropriate exit code:
https://doc.rust-lang.org/std/process/struct.ExitCode.html#associatedconstant.FAILURE

The only caveat is that `FF2MpvError` has to implement `Debug`, but
instead of deriving it I cheated a bit and re-used the existing
`Display` implementation to preserve the format of the error messages.
2023-10-29 16:05:45 +01:00