Follow these steps to create a simple application that searches the filesystem:
- Create a new project using cargo new child-processes and open it in Visual Studio Code.
- On Windows, execute cargo run (the last step) from a PowerShell window, since it contains all the required binaries.
- After importing a few (standard library) dependencies, let's write the basic struct to hold the result data. Add this on top of the main function:
use std::io::Write;use std::process::{Command, Stdio};#[derive(Debug)]struct SearchResult { query: String, results: Vec<String>,}
- The function calling the find binary (which does the actual searching) translates the results into the struct from step 1. This is what the function looks like: