Rust
Build Service Tutorial · Tips & Tricks · Cross Distribution Howto · Packaging checks
Desktop menu categories · RPM Macros · Scriptlets · Init scripts · How to write good changes
Rust is a multi-paradigm, 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. To simultaneously enforce memory safety and prevent concurrent data races, Rust's "borrow checker" tracks the object lifetime of all references in a program during compilation. Rust is popular for systems programming but also offers high-level features including some functional programming constructs.
Install Rust
For Rust programming, You need the following tools:
- Rust (the compiler, linker and debugger)
- Cargo (the package manager)
- Text editor of your choice
For most users, you only need to install the stable version of Rust and Cargo. This can be done in one single command:
sudo zypper install rustup rustup toolchain install stable
You can then update your toolchains at any time with.
rustup update
For advanced users who need nightly version of Rust, you can install rustup and then install nightly version of Rust:
sudo zypper install rustup rustup toolchain install nightly
If you wish to build against the version of rust that is used in OpenSUSE for package building (not recommended) you can use:
sudo zypper rm rustup sudo zypper install cargo
Note the distributed version of rust does not have the language server or other IDE integrations.
Create a Rust project
Cargo is the package manager of Rust. And it can also create Rust projects:
cargo new world_hello cd world_hello
The created project has the following structure:
├── .git ├── .gitignore ├── Cargo.toml # the project information and dependencies └── src └── main.rs # the main source code
To quickly run your project:
cargo run
You will see output like:
Compiling world_hello v0.1.0 (/home/bob/world_hello) Finished dev [unoptimized + debuginfo] target(s) in 0.43s Running `target/debug/world_hello` Hello, world!
Learn Rust Programming
Packaging Software Written in Rust
See the detailed packaging guide: Packaging Rust Software
To help improve OBS/IBS performance, you may also wish to Enable sccache for improving rebuild times
Packaging the Rust Compiler
See the detailed guide: Packaging Rustlang
Rust in OpenSUSE Survey Results
September 2021
Analysis - maintainer writeup
Report from rust survey - combined partial and full results
Full report from the rust survey - fully complete results