Sometime ago I started to learn Rust, first by reading resources like The rust book and Rust by example. Then I continue with the rustlings exercises and now I decided to continue with Rust in motion video course.
This are some notes that I have been taking…
The Rust toolchain installer, and we can use it for install, update and switch between
To install rustup, run this command in a terminal
Or if you are on window download the
rustup-init.exe file from this page
rustup allow us to check the updates and update our rust version
For example we can add the
webAssembly target by running
Cargo is the package manager of rust ( like
npm to node.js )
$ cargo new –bin myproject
$ cargo new –lib myproject
--lib allow us to crate a new executable project or a new library project ( e.g a crater ).
Cargo also will create the directory with a
Cargo.toml file ( like the
package.json of node.js and a
src directory with a boilerplate code.
Cargo also allow us to build ( and install the dependencies ) and run the project
Cargo will automatically create the file Cargo.lock to keep track of the deps ( like package-lock.json for node.js ) and a
target directory. By default cargo compiles the executable in the
debug directory with a very few optimizations and if you want to compile a
release version you should run
This will generate the executable ( with optimizations ) in the
Also, you can
run with one command.
This is all for now, next note will be about
syntax and I will try to generate and example project…
Note: also published in collected notes/javier
Author Javier Viola