Ben Chuanlong Du's Blog

It is never too late to learn.

Tips on Cargo

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Create a Project

cargo init
cargo new project_name
cargo new --lib project_name

Install a Rust Crate (Package)

Install a Rust crate from GitHub (the default branch).

cargo install --git https://github …

Tips on rustup

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Install rustup

Linux and macOS

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y

Rust tools (rustc, cargo, rustup, etc) will be added to Cargo's bin directory …

Tips on Rustfmt

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Configuring Rustfmt

tab_spaces = 4
max_width = 90
chain_width = 70
newline_style = "unix"
use_field_init_shorthand = true
use_small_heuristics = "Max"

References

https://github.com/rust-lang/rustfmt