October 2019
Intermediate to advanced
444 pages
10h 37m
English
This recipe quickly covers some abilities of the Rust std::process::Command struct. After setting everything up in steps 1 and 2, we create the main function in step 3. Using Result<(), Box<dyn Error + ...>> with a boxed dyn trait (https://doc.rust-lang.org/edition-guide/rust-2018/trait-system/dyn-trait-for-trait-objects.html) as the return type for the main function allows us to use the ? operator instead of unwrap(), expect(), or other constructs—regardless of the actual error type.
We start off by using the ls command, which lists the directory contents. Except for Windows, the program takes arguments to expand the output:
Read now
Unlock full access