Originally published on php2rust.dev — part of the PHP to Rust course. View this lesson on the original site.
Instead of running cargo build and then executing the binary yourself, use:
cargo run
This compiles the project if needed and runs the binary. If nothing changed since the last build, Cargo skips recompilation and runs the existing binary.
By default it uses the debug build. For a release build:
cargo run --release
What's next
Next: Initializing a new Rust project with cargo init.
From PHP to Rust — Getting Started with Rust