Rust 及其包管理Cargo的安裝使用
阿新 • • 發佈:2021-08-08
Rust 公眾號 https://mp.weixin.qq.com/s/aRGY6oLXVQzxbb1wb3RGcA
Rust 中文社群教程 https://rustcc.gitbooks.io/rustprimer/content/quickstart/rust-travel.html
安裝
see more: https://www.rust-lang.org/zh-CN/tools/install
$CARGO_HOME/config.toml which defaults to: Windows: %USERPROFILE%\.cargo\config.toml Unix: $HOME/.cargo/config.toml
Note: Cargo also reads config files without the .toml extension, such as .cargo/config. Support for the .toml extension was added in version 1.39 and is the preferred form. If both files exist, Cargo will use the file without the extension.
在 config 檔案中新增如下內容:
[source.crates-io] replace-with = 'ustc' [source.ustc] registry = "git://mirrors.ustc.edu.cn/crates.io-index"
如果所處的環境中不允許使用 git 協議,可以把上述地址改為:
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
其他映象源:
https://rsproxy.cn
更新 Rust
network-proxy https://rust-lang.github.io/rustup/network-proxies.html
## 官方直連 rustup update ## 使用映象源 see: https://mirrors.ustc.edu.cn/help/rust-static.html # PowerShell $env:RUSTUP_DIST_SERVER="https://mirrors.ustc.edu.cn/rust-static" $env:RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup" rustup update
初始化當前目錄為Rust專案
cargo install
更新專案依賴
cargo update
開發環境
VSCode + Rust
WEB 框架
Rocket
actix-web