rustc main.rs -o output && ./output
rustc main.rs -o output && .\output.exe
Cargo is Rust’s build system and package manager.
cargo new hello_cargo
cd hello_cargo
cargo build
This command creates an executable file in target/debug/hello_cargo (or target\debug\hello_cargo.exe on Windows) rather than in your current directory
You can run
./target/debug/hello_cargo
or .\target\debug\hello_cargo.exe
on Windows
or you can also run your project using the comands
cargo run
Noted: Cargo also provides a command called cargo check. This command quickly checks your code to make sure it compiles but doesn’t produce an executable:
cargo add <lib_name>