Install Rust in WSL

openSUSE Leap 15.5 was installed to Windows Subsystem for Linux in a previous page.

The instructions are derived from https://www.rust-lang.org/learn/get-started

Installing Rust Update (rustup)

Open a terminal for the Linux system.

Log in as the preferred user.

Install rustup:
sudo zypper install rustup

Use rustup to install the latest stable toolchain:
rustup install stable

Check the default toolchain name and cargo version:
rustup default
cargo --version

Create hello-rust project

Change to the directory to store projects.

Run cargo new to create a new project:
cargo new hello-rust

It should return "Created binary (application) `hello-rust` package".  If you see "error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured" then run rustup default stable.

Run the program, which will compile it as necessary:
cd hello-rust
cargo run hello-rust

Set up other targets

The default Rust toolchain will target the system it is installed on.  Binaries can be built for other platforms; this is a good idea, since most people are not running  WSL+OpenSUSE.

Note that each user has their own list of targets and default target.

To set up the WASM/WASI target for the local user:
rustup target add wasm32-wasi

You can see the complete list by running rustup target list