Rust

From Alliance Doc
Jump to navigation Jump to search
Other languages:

Rust is a multi-paradigm, high-level, general-purpose programming language. Rust emphasizes performance, type safety, and concurrency. Rust enforces memory safety — that is, that all references point to valid memory — without requiring the use of a garbage collector or reference counting present in other memory-safe languages.

Module

The Rust compiler is available as a module.

Question.png
[name@server ~]$ module spider rust

Installing a crate

A package written in Rust is called a crate.

1. Load the required modules.

Question.png
[name@server ~]$ module load gcc/9.3.0 rust

2. Build and install the crate locally. This must be done from a login node.

Question.png
[name@server ~]$ cargo install ungoliant

3. Test the binary.

Question.png
[name@server ~]$ $HOME/.cargo/bin/ungoliant -h

You can also add .cargo/bin to your $PATH with: export PATH="$HOME/.cargo/bin:$PATH".

Using the Rust nightly compiler

Since some optimization features are not yet stable they are not part of the stable release, but nonetheless some crates make use of them. If you require the Rust nightly compiler, you can install it locally.

1. Install the compiler as a local module.

Question.png
[name@server ~]$ eb Rust-1.53.0.eb --try-software-version=nightly --disable-enforce-checksums

2. Load the local module.

Question.png
[name@server ~]$ module load rust/nightly