Learn Rust via the Rust Programming Language book. The book can be accessed offline with rustup docs --book
.
Everything will be done via *NIX operating systems.
See the book to adopt the notes for a Windows enviroment.
Learn Rust in Y minutes is also a nice source for notes.
https://doc.rust-lang.org/stable/rust-by-example/flow_control/if_let.html
Install and update path: curl https://sh.rustup.rs -sSf | sh
and source $HOME/.cargo/env
. Keep up to date by running rustup update
.
Install the automatic formatter (same as linter?) via rustup
:
rustup component add rustfmt
. The formatter is invoked by
Format the code, compile and run:
rustfmt main.rs && rustc main.rs && ./main
fn main()
is always needed.
A macros i denoted by !. So println!
calls a macro,
and println
calls a function.
In Rust, packages of code are referred to as crates. Cargo expects your source files to live inside the src directory.
When creating a new crate a directory structure will be created and initiated with a git repository.
Crete new: cargo new hello_cargo
; check: cargo check
; build: cargo build
;
build for release: cargo build --release
;
build documentation provided by all of your dependencies locally and open it in your browser: cargo doc --open
.
loop {
break;
}