Here’s the translation of the Go code to Rust, with explanations in Markdown format suitable for Hugo:
In the previous example, we looked at spawning external processes. We do this when we need an external process accessible to a running Rust process. Sometimes we just want to completely replace the current Rust process with another (perhaps non-Rust) one. To do this, we’ll use Rust’s implementation of the classic exec function.
When we run our program it is replaced by ls.
Note that Rust, like many other languages, does not offer a classic Unix fork function. Usually this isn’t an issue though, since spawning processes and exec’ing processes covers most use cases for fork. For more complex scenarios, Rust provides the std::process module which offers fine-grained control over process creation and management.