In your terminal , Type this command line cargo new <project name>
and you can check boilerplate in your project file.
fn main() {
println!("Hello, world!");
}
rustc <filename>
if you want to compile it as binary code../maiu.exe
Rust is an ahead-of-time compiled language.
Languages such as Ruby, Python, or Javascript is needed to give its file to execute them.
But in compiled language, you only need to compile and can give the executable program to someone else.
Cargo is build system and package manager. (sounds like npm in node?)
You can check if cargo works or not with cargo --version
in your terminal.
create a project with cargo
cargo new <project name>
src directory
Cargo expects your source files to live inside in src directory
Cargo.toml
Where cargo treats dependencies
building and running a cargo project
cargo build
It generates executable program in 'target/debug' path as your project name.
easy way to compile and run altogether
cargo run
If you had modified any code, Cargo would rebuilt the project before running it by compiling again.
Speed up your development
cargo check
It doesn't product anything, just check. So it can be able to make your development speed faster.
Recap