Getting Started with Rust
This tutorial series is minified version of The Rust Book: The Rust Programming Language
and follow up of this tutorial series:
So, if you like watching video tutorial, do check out the above series by Bogdan Pshonyak and follow up with the notes here.
If you do give this quick read and test yourself while diving deep, then checkout this :
Installing Rust on Linux or macOS
Check Rust version with:
Then go ahead and install official Plugin/extensions for Rust and Rust-analyzer for your faviourite IDE.
Hello, World in Rust
And then write in
Let's compile this and run this:
In real world projects we're going to work with multiple files with dependencies and therefore we need a build system and package manager: Cargo.
Check it's version as:
Let's create a new package named
In Rust the package names are supposed to be in all smallcase.
Cargo.toml contains information about the package, and list dependencies along with their aliases.
[package] name = "hello_cargo" version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies]
To build using Cargo, let's cd into our newly created directory:
cd hello_cargo and then:
cargo.lock(don't temper with this)
targetdir which contains bunch of other stuff and main executable file.
cargo --help to see more bunch of options.
You can use
cargo check to check program for errors without actually building an executable file, much faster.
The default tools on the rustup toolchain are:
- Cargo: package manager and crate host for Rust
- Rustup: the rust toolchain installer/updater/release switcher
- Rustc: the rust compiler
To update Rust, simply run:
and to uninstall: