“the book”
Affectionately nicknamed “the book,” The Rust Programming Language will give you an overview of the language from first principles. You’ll build a few projects along the way, and by the end, you’ll have a solid grasp of the language.
Although many seasoned developers may prefer to jump straight into experimenting building programs in Rust, it may still be worthwhile to start with reading about ownership and lifetimes before jumping into Rust. Coming from a background of professional experience using Elm and Typescript and working on side projects with Elixir and Haskell, I already had used functional programming but it might be good to review that section as well.
cargo-watch
https://github.com/passcod/cargo-watch
cargo install cargo-watch
cargo watch -x "test -- --nocapture"
cargo-watch
is a useful command line tool for saving time in your iteration cycles. Just run cargo watch -x test
in one of your windows and it will continuously install new pacakges, build, and run tests for your program.
If you don’t want to constantly change what is running in your cargo watch
command, you could execute a wrapper script so that you can just update the script instead of using Ctrl-C
in the terminal pane where you are running the cargo watch
.
For example, run cargo watch -s './run.sh'
#!/bin/bash
# run.sh
set -e
export RUST_LOG="sample_app=info"
# avoid printing rustc warnings which are probably also visible in your editor
cargo rustc --bin sample-app -- -Awarnings && \
target/debug/sample-app sample-arg.txt
cargo-edit
https://github.com/killercup/cargo-edit
If you ever find yourself wishing for an easier way to add packages without having to look up the version and then opening your Cargo.toml
and adding a line, look no further!
Run cargo install cargo-edit
and then you can run cargo add [dependency]
, cargo rm [dependency]
and even cargo update
to update all your dependencies.
clippy
https://github.com/rust-lang/rust-clippy
Clippy is a linting tool to help improve your code. After installing it, you can run cargo clippy
to see the suggestions and cargo fix -Z unstable-options --clippy
to automatically apply the suggestions. If you use VS Code, you can also enable Clippy suggestions in your settings in order to view the Clippy suggestions and explanations in your code.