Rust 及其包管理Cargo的安装使用

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"

  1. https://mirrors.ustc.edu.cn/help/crates.io-index.html

  2. https://doc.rust-lang.org/cargo/reference/config.html

其他镜像源:
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

上一篇:P1004 [NOIP2000 提高组] 方格取数


下一篇:PHP-为什么这一行代码不需要转义引号