Skip to content

Latest commit

 

History

History
117 lines (77 loc) · 2.11 KB

ch_01.md

File metadata and controls

117 lines (77 loc) · 2.11 KB

Chapter 1 - Getting Started

Installing Tools 🛠

These notes are specific and targeted for macOS

First Time?

Need to install rustup

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

Faster linker

Supposed to cut down on compile times.

Brew install then set with .cargo/config.toml

Install:

brew install michaeleisel/zld/zld

Usage:

.cargo/config.toml

# On Windows
# ```
# cargo install -f cargo-binutils
# rustup component add llvm-tools-preview
# ```
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

[target.x86_64-pc-windows-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

# On Linux:
# - Ubuntu, `sudo apt-get install lld clang`
# - Arch, `sudo pacman -S lld clang`
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"]

# On MacOS, `brew install michaeleisel/zld/zld`
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"]

Cargo Watch

Cargo Watch watches over your project's source for changes, and runs Cargo commands when they occur.

💭 Kind of like nodemon

Install:

# had to install binstall because other way wasn't working
cargo install cargo-binstall

cargo binstall cargo-watch

Usage:

# on file change
cargo watch -x check

# on file change: check, test, run
cargo watch -x check -x test -x run

Code Coverage

Tarpaulin is a code coverage reporting tool for the Cargo build system, named for a waterproof cloth used to cover cargo on a ship.

Currently, tarpaulin provides working line coverage and while fairly reliable may still contain minor inaccuracies in the results.

Install:

cargo install cargo-tarpaulin

Usage:

cargo tarpaulin --ignore-tests

Linter

Clippy is the official linter maintained by the rust team

Install:

rustup component add clippy

Usage:

cargo clippy

# for CI
cargo clippy -- -D warnings