---
# System prepended metadata

title: Rust Workshop

---

# Rust Workshop

## Prerequisites
* Install Rust using [`rustup`](https://www.rust-lang.org/tools/install)
  * Use the **default** profile
  * > The installer might ask you to install MSVC build tools. In order to do that, install [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) and select the workloads “Desktop Development with C++”, The Windows 10 or 11 SDK and the english language pack.
  * Verify Rust installation with `rustc --version`
* Install [CLion](https://www.jetbrains.com/clion/download/) (requires [JetBrains student license](https://www.jetbrains.com/community/education/#students))
  * Install the [Rust plugin](https://plugins.jetbrains.com/plugin/8182-rust)
  * Install the [Toml plugin](https://plugins.jetbrains.com/plugin/8195-toml)
  * Configure CLion to use `rustfmt`: ![](https://i.imgur.com/wNR43bV.png)
  * Configure CLion to use `Clippy`: ![](https://i.imgur.com/vRBt1to.png)
    * Note: Enabling "Run external linter to analyze code on the fly" will give you very helpful tips in the IDE -- but this might cause performance degredation in the editor. My recommendation is to enable it, and if you notice any slowdowns try disabling it.
* Install [Python 3.4 or later](https://www.python.org/downloads/) (need it for `pip`)
  * Verify pip installation with `pip --version`

## Tasks
1. Create and run a hello world application in Rust using Cargo by following [this guide](https://doc.rust-lang.org/book/ch01-03-hello-cargo.html)
2. Create a (very basic -- e.g. `assert 1+1 == 2`) unit test in the hello world application: see [this page](https://doc.rust-lang.org/book/ch11-01-writing-tests.html) for how to write a test, and run it using CLion
3. Install nightly Rust by running `rustup toolchain install nightly`
4. Switch to nightly globally by running `rustup default nightly`
5. Clone and run [recs-gfx](https://github.com/martinjonsson01/gfx/)
6. Install pre-commit hooks according to instructions in `recs-gfx` README

## Concurrency primitives demo
* Channels fibonacci example (taken from [here](https://github.com/crossbeam-rs/crossbeam/blob/master/crossbeam-channel/examples/fibonacci.rs))
* `Arc<Mutex<T>>` example (locking)
  * For a great explanation of what `Rc<T>` is, see [The Book](https://doc.rust-lang.org/book/ch15-04-rc.html)
  * A description of [what interior mutability is](https://doc.rust-lang.org/book/ch15-05-interior-mutability.html)
  * Based on [this chapter in The Book](https://doc.rust-lang.org/book/ch16-03-shared-state.html)

## Further reading
See **Learning Rust** in [Rust resources](/0XBXApcLQlaBog7_dVLQpQ)
* In particular, the [Rust for Java developers](https://github.com/andyrbell/rust-for-java-developers/wiki/Lab-part-01) interactive tutorial is great as a surface-level introduction to the language