A guide to Rust from a node.js developer’s perspective.
Welcome to our 24-post series on getting started with Rust! Each day until Christmas (December 25th 2021) you’ll find another post taking something you know how to do in node.js and translating it to Rust. Today kicks off with you setting up Rust via a tool similar to
rustup. Next up we’ll tackle
- Day 1: From nvm to rustup
- Day 2: From npm to cargo
- Day 3: Setting up VS Code
- Day 4: Hello World (and your first two WTFs)
- Day 5: Borrowing & Ownership
- Day 6: Strings, part 1
- Day 7: Syntax and Language, part 1
- Day 8: Language Part 2: From objects and classes to HashMaps and structs
- Day 9: Language Part 3: Class Methods for Rust Structs (+ enums!)
- Day 10: From Mixins to Traits
- Day 11: The Module System
- Day 12: Strings, Part 2
- Day 13: Results & Options
- Day 14: Managing Errors
- Day 15: Closures
- Day 16: Lifetimes, references, and
- Day 17: Arrays, Loops, and Iterators
- Day 18: Async
- Day 19: Starting a large project
- Day 20: CLI Arguments & Logging
- Day 21: Building and Running WebAssembly
- Day 22: Using JSON
- Day 23: Cheating The Borrow Checker
- Day 24: Crates & Tools
Day 1: Installing rust with
The equivalent in Rust’s world is rustup.
Rustup manages your Rust installation as well as additonal targets (like WebAssembly) and core tools like
rustup, run it without any subcommands and explore what it has to offer.
rustup show will show you what is currently installed.
rustup completions will help you enable CLI autocompletion for tools like
rustup component lets you add additonal components.
rustup update will update you to the latest version.
rustup install stable|nightly|1.57 will install a specific version or the latest stable/nightly versions.
By default, rustup will install the latest version of
cargo and you should be ready to go right away. Give it a shot with.
If it doesn’t work, you may need to restart your shell to update your PATH.
Specifying your toolchain with rustup is easy enough. As you get deeper, you may get into configurations where different projects require different toolchains or Rust versions. That’s where
rust-toolchain.toml comes into play. Specify your project’s required toolchain, targets, and supporting tools here so that
rustup can work automagically, e.g.
Next up we’ll take a look at
npm and the additional tools that will help reach parity with common workflows: Day 2: From npm to cargo.