使用 Cargo
您開始閱讀 Rust 內容後,很快就會認識 Cargo,這是在 Rust 生態系統中使用的標準工具,用於建構及執行 Rust 應用程式。以下簡要介紹 Cargo,以及如何在更廣大的生態系統和本訓練課程中運用 Cargo。
安裝
請按照 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/switch toolchains, setup cross compilation, etc.
- 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