4.1 Compiling with Rustc
The Rust compiler, rustc
, is the fundamental tool for compiling Rust programs. To compile a single Rust source file, you can run the following command in your terminal:
rustc main.rs
This command will compile the file main.rs
into an executable. You can then run the executable directly from the command line. While this method works well for small, simple projects, managing more complex projects with multiple files and dependencies becomes cumbersome without a dedicated build system.