preface
Rust’s learning curve is steep enough that it can be difficult even for systems programmers. But Rust has the best support for WebAssembly, so for Web programmers, you can rewrite CPU-intensive JavaScript logic in Rust and run it in WebAssembly, and the combination of JavaScript and Rust will give you control over everything.
This tutorial is not intended to be exhaustive, but you should have some experience with Node.js, and you’ll see comparisons of JavaScript, TypeScript, and Rust to help you understand.
The body of the
In the Node.js world, we use NVM or NVM-Windows to seamlessly install and switch between different versions of Node.js. The counterpart in the Rust world is Rustup
Rustup manages Rust installations and additional build targets such as WebAssembly, in addition to core tools such as Cargo (NPM for Rust), Clippy (ESLint for Rust), and RustFMT (Prettier for Rust). Before using Rust, we first install Rustup[install connection]. After installing Rustup, we see the following results when we execute Rustup:
$ rustup
rustup 1.24.3 (ce5817a94 2021- 05- 31)
The Rust toolchain installer
USAGE:
rustup [FLAGS] [+toolchain] <SUBCOMMAND>
FLAGS:
-v, --verbose Enable verbose output
-q, --quiet Disable progress output
-h, --help Prints help information
-V, --version Prints version information
ARGS:
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override
SUBCOMMANDS:
show Show the active and installed toolchains or profiles
update Update Rust toolchains and rustup
check Check for updates to Rust toolchains and rustup
default Set the default toolchain
toolchain Modify or query the installed toolchains
target Modify a toolchain's supported targets component Modify a toolchain's installed components
override Modify directory toolchain overrides
run Run a command with an environment configured for a given toolchain
which Display which binary will be run for a given command
doc Open the documentation for the current toolchain
man View the man page for a given command
self Modify the rustup installation
set Alter rustup settings
completions Generate tab-completion scripts for your shell
help Prints this message or the help of the given subcommand(s)
DISCUSSION:
Rustup installs The Rust Programming Language from the official
release channels, enabling you to easily switch between stable,
beta, and nightly compilers and keep them updated. It makes
cross-compiling simpler with binary builds of the standard library
for common platforms.
If you are new to Rust consider running `rustup doc --book` to
learn Rust.
Copy the code
By default, Rustup installs the latest versions of Rust and Cargo:
$cargo -- Version Cargo 1.6.0 (4ED5D137B 2021-10-04) $cargo -- Version Cargo 1.6.0 (4ED5D137B 2021-10-04)Copy the code
Related links
- Rust Tutorial (2) for the front-end: FROM NPM to Cargo