From 859a48cc91c655e7cf9d4b5b6ec473dc76b9e0f0 Mon Sep 17 00:00:00 2001 From: tiyn Date: Sun, 12 Oct 2025 06:26:11 +0200 Subject: [PATCH] programming languages: added rust --- wiki/programming_language/rust.md | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 wiki/programming_language/rust.md diff --git a/wiki/programming_language/rust.md b/wiki/programming_language/rust.md new file mode 100644 index 0000000..33ee283 --- /dev/null +++ b/wiki/programming_language/rust.md @@ -0,0 +1,61 @@ +# Rust + +[Rust](https://www.rust-lang.org/) is a multiparadigm compiled systems programming language. + +## Setup + +Rust can be setup as explained on the [Rust website](https://rust-lang.org/tools/install/). +It is always recommended to install Rust via rustup. +Alternatively many [Linux](/wiki/linux.md) [package managers](/wiki/linux/package_manager.md) +package rustup in the `rustup` package. + +## Usage + +This section addresses the usage of Rust. + +### Create a New Project + +To create a new project use the command `cargo`. +The following is an example in which `` is a placeholder for the projects name. +It will create a new directory called the same as the given project name. + +```sh +cargo new +``` + +If a project parent directory is already present the following command can be used which will turn +the parent directory in the root directory for a project. + +```sh +cargo init +``` + +### Running Programs and Projects + +When inside a project the main file can simply be run by using the following command. +This command can be called from anywhere within the project folder structure. + +```sh +cargo run +``` + +If no project was initialized and just a Rust file is present run a command simliar to the +following, where `` is the name of the Rust file without the `.rs`-extension. + +```sh +rustc .rs +./ +``` + +### Managing Packages and Libraries + +To use external libraries or packages `cargo` project has to be present since it is used to manage +them. +Using the following command a package can be downloaded and added to the dependencies for the +project. +`` is a placeholder for the name of the package (for example `z3` for the theorem +prover). + +```sh +cargo add +```