Rust

Revision as of 15:31, 26 January 2023 by Coulombc (talk | contribs) (Added Rust page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.

 
[name@server ~]$ module spider rust

Installing a crate

A package written in Rust is called a crate.

1. Load the required modules.

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

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

 
[name@server ~]$ cargo install ungoliant

3. Test the binary.

 
[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.

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

2. Load the local module.

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