Rust: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
(Added Rust page)
 
(Marked this version for translation)
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
<translate>
<translate>


<!--T:1-->
[https://www.rust-lang.org/ 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.
[https://www.rust-lang.org/ 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 ==  
== Module == <!--T:2-->
The Rust compiler is available as a [[Utiliser_des_modules/en|module]].
The Rust compiler is available as a [[Utiliser_des_modules/en|module]].
{{Command|module spider rust}}
{{Command|module spider rust}}


== Installing a crate ==
== Installing a crate == <!--T:3-->
A package written in Rust is called a [https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html ''crate''].
A package written in Rust is called a [https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html ''crate''].


<!--T:4-->
1. Load the required modules.
1. Load the required modules.
{{Command|module load gcc/9.3.0 rust}}
{{Command|module load gcc/9.3.0 rust}}


2. Build and install locally the crate. This must be done from a login node.
<!--T:5-->
2. Build and install the crate locally. This must be done from a login node.
{{Command|cargo install ungoliant}}
{{Command|cargo install ungoliant}}


<!--T:6-->
3. Test the binary.
3. Test the binary.
{{Command|$HOME/.cargo/bin/ungoliant -h}}
{{Command|$HOME/.cargo/bin/ungoliant -h}}


You can also add <tt>.cargo/bin</tt> to your <tt>$PATH</tt> with: <tt>export PATH="$HOME/.cargo/bin:$PATH"</tt>.
<!--T:7-->
You can also add <code>.cargo/bin</code> to your <code>$PATH</code> with: <code>export PATH="$HOME/.cargo/bin:$PATH"</code>.


== Using the rust-nightly compiler ==  
== Using the Rust nightly compiler == <!--T:8-->
Since some optimization features are not yet stable they are not part of the stable release, but nonetheless some crates make use of them.
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.
If you require the Rust nightly compiler, you can install it locally.


<!--T:9-->
1. Install the compiler as a local module.
1. Install the compiler as a local module.
{{Command|eb Rust-1.53.0.eb --try-software-version{{=}}nightly --disable-enforce-checksums}}
{{Command|eb Rust-1.53.0.eb --try-software-version{{=}}nightly --disable-enforce-checksums}}


<!--T:10-->
2. Load the local module.
2. Load the local module.
{{Command|module load rust/nightly}}
{{Command|module load rust/nightly}}


</translate>
</translate>

Latest revision as of 17:11, 30 January 2023

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