This post aims to document the learning and development of my personal Rust programming mini adventure.
Note:
The following information comes from bits and pieces of information that I've gathered to self learn and document. So it means you can find the information from oficial sites and elsewhere on the Internet too :)
Will update this post as I find more resources and fill in gaps/lack of in the information provided here.
Readings:
Links | Description |
---|---|
https://doc.rust-lang.org/book | API overview, installation, general overall language resouces |
The following command is to install Rust onto Linux / Mac systems.
$ curl https://sh.rustup.rs -sSf | sh
$ rustup --update
$ rustc --version
Just like NodeJS's NPM, for Rust there's the Cargo. Cargo is Rust’s build system and package manager. Most Rustaceans use this tool to manage their Rust projects because Cargo handles a lot of tasks for you, such as building your code, downloading the libraries your code depends on, and building those libraries. (We call libraries your code needs dependencies.)
You can use the following command to check the version of Cargo currently on your system:
$ cargo --version
Project initialisation:
The easiest method to start a Rust project is to use the following set of commands:
$ touch learn_rust.rs
// sample starter code.
fn main() {
println!("Hello, world!");
}
$ rustc build
$ rustc run
The better way to start a brand new project would be to init the package manager with Cargo to properly start the actual project.
$ cargo init
To run the project, you have the option of building the project as is for just development.
For production level optimised build you have the option to run a command to let the code that you've built run even more effeciently and faster:
$ cargo build --release
$ cargo run
Definitely, in situations where you wanna check the code for errors before running it there's a command to do checking first before turning the code into an executable:
$ cargo check
Setting up a new project:
To set up a new project, head over to the directory and type the following command:
$ cargo new <project name>
In Summary
- Install the latest stable version of Rust using rustup
- Update to a newer Rust version
- Open locally installed documentation
- Write and run a Hello, world! program using rustc directly
- Create and run a new project using the conventions of Cargo #
Top comments (0)