Rust Notes

Rust Notes

Rust playground website

https://play.rust-lang.org/

Tutorials websites

https://stevedonovan.github.io/rust-gentle-intro/1-basics.html

Setup dev env

https://hoverbear.org/2017/03/03/setting-up-a-rust-devenv/

Setup rust with Rustup

website https://rustup.rs/

website on how to use it https://rust-lang-nursery.github.io/edition-guide/rust-2018/rustup-for-managing-rust-versions.html

curl https://sh.rustup.rs -sSf | sh

location of all rustup install and files $HOME/.cargo/bin

Rustup use

Install bash completions (Optional)

rustup completions bash > /etc/bash_completion.d/rustup.bash-completion 

Updating rustup

rustup self update

Install stable toolchain

rustup install stable

Nightly

Install Nightly toolchain

rustup install nightly

Set Nightly as default

rustup default nightly

updating rust toolchains

rustup update

Rustup Components

List components which can be installed on your system

rustup component list

Install components

Install clippy tool used for compiling code with hints

rustup component add clippy

Install rust-fmt tool used for auto code formatting

rustup component add rust-fmt

Install rls tool used for rust lanuage server for ide’s

rustup component add rls

IDE tools

racer https://github.com/racer-rust/racer - Code completeion

Install with cargo

cargo +nightly install racer

Tools

Cargo-bloat

website https://github.com/RazrFalcon/cargo-bloat

Install cargo-bloat tool

cargo install cargo-bloat

To get size of the release

cargo bloat --release

website https://github.com/dtolnay/cargo-expand Install cargo expand to expand code to the std output

cargo install cargo-expand

Run expand

cargo expand

make binary size smaller

File Cargo.toml add to bottom of the file.

[profile.release]
debug = false
lto = true
opt-level = 'z'

Remove debug symbols from the binary to make it smaller

strip -d rustbinary
Share