Rust is a multi-paradigm, general-purpose programming language that emphasizes performance, type safety, and concurrency. It enforces memory safety-meaning that all references point to valid memory-without a garbage collector. To simultaneously enforce memory safety and prevent data races, its “borrow checker” tracks the object lifetime of all references in a program during compilation.
Rust was influenced by ideas from functional programming, including immutability, higher-order functions, and algebraic data types. It is popular for systems programming.
Software developer Graydon Hoare created Rust as a personal project while working at Mozilla Research in 2006. Mozilla officially sponsored the project in 2009. In the years following the first stable release in May 2015, Rust was adopted by companies including Amazon, Discord, Dropbox, Google (Alphabet), Meta, and Microsoft. In December 2022, it became the first language other than C and assembly to be supported in the development of the Linux kernel.
Rust has been noted for its rapid adoption, and has been studied in programming language theory research.
https://www.rust-lang.org/
https://www.rust-lang.org/learn|Rust Documentation - Learning Rust]]
Rust Documentation - Getting started
The Rust community’s crate registry
Manual pages:
user@host:~$ man 1 rustc user@host:~$ man 1 rustdoc user@host:~$ man 1 cargo user@host:~$ man 1 cargo-<SUBCOMMAND>
Builtin Cargo help:
user@host:~$ cargo help user@host:~$ cargo help <SUBCOMMAND> user@host:~$ cargo <SUBCOMMAND> --help
To install Rust and its build toolchain and package manager Cargo on Debian:
root@host:~$ apt-get -y install rustc cargo
To install Rust and its build toolchain and package manager Cargo from a more recent version on Debian:
root@host:~$ apt-get -y install rustc-mozilla cargo-mozilla
user@host:~$ cargo new hello_world
Compile and run a project *with* debugging information:
user@host:~$ cd hello_world user@host:~/hello_world$ cargo run user@host:~/hello_world$ du -sm target/debug/hello_world
Compile and run a project *optimized* and *without* debugging information:
user@host:~/hello_world$ cargo run --release
Clean a project from the artefacts of a previous compile and run:
user@host:~/hello_world$ cargo clean
Add a external library dependency to a project. E.g. ferris-says
:
user@host:~/hello_world$ cargo add ferris-says
Manually add a external library dependency to a project. E.g. ferris-says
:
user@host:~/hello_world$ vi Cargo.toml
File contents:
[...] [dependencies] ferris-says = "0.2.1"
Update the projects main code:
user@host:~/hello_world$ vi src/main.rs
File contents:
use ferris_says::say; use std::io::{stdout, BufWriter}; fn main() { let stdout = stdout(); let message = b"Hello fellow Rustaceans!"; let width = 24; let mut writer = BufWriter::new(stdout.lock()); say(message, width, &mut writer).unwrap(); }
Compile and run the updated project:
user@host:~/hello_world$ cargo run
Set a first and second level dependency to a specific version in a project:
user@host:~/hello_world$ cargo update -p unicode-width --precise 0.1.7 user@host:~/hello_world$ cargo update -p smawk --precise 0.3.0
To check the status of :
root@host:~$