Cargo verwenden

Wenn du anfängst über Rust zu lesen, wirst du sehr bald Cargo, ein Standardwerkzeug, welches im Rust-Ökosystem verwendet wird, um Rust-Anwendungen zu erstellen und auszuführen, kennenlernen. Hier wollen wir einen kurzen Überblick geben, was Cargo ist und wie es in das breitere Ökosystem und in dieses Training passt.

Installation

Bitte folgt den Anweisungen auf https://rustup.rs/.

This will give you the Cargo build tool (cargo) and the Rust compiler (rustc). You will also get rustup, a command line utility that you can use to install to different compiler versions.

After installing Rust, you should configure your editor or IDE to work with Rust. Most editors do this by talking to rust-analyzer, which provides auto-completion and jump-to-definition functionality for VS Code, Emacs, Vim/Neovim, and many others. There is also a different IDE available called RustRover.

  • On Debian/Ubuntu, you can also install Cargo, the Rust source and the Rust formatter via apt. However, this gets you an outdated Rust version and may lead to unexpected behavior. The command would be:

    sudo apt install cargo rust-src rustfmt
    
  • On macOS, you can use Homebrew to install Rust, but this may provide an outdated version. Therefore, it is recommended to install Rust from the official site.