Rust安装配置

Rust安装配置

简介

  • rust官方提供了一系列工具,用于rust的开发及管理, 包括:
    • rustup
    • cargo

安装

  • rust官方提供了rustup用于rust的安装管理;
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 安装rustup, rustc, cargo
curl https://sh.rustup.rs -sSf | sh
# 安装源码, rls
rustup component add rust-src rls
# 启用国内rustup 清华镜像(bash)
echo 'export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup' >> ~/.bash_profile
# 启用国内rustup 清华镜像(fish)
echo 'set -x RUSTUP_DIST_SERVER https://mirrors.tuna.tsinghua.edu.cn/rustup' >> ~/.config/fish/config.fish
# 切换nightly版
rustup override set nightly
# 切换stable版
rustup override set stable

使用科大 rust 镜像加速国内环境

1
2
3
4
5
6
7
8
# ~/.cargo/config
[registry]
index = "https://mirrors.ustc.edu.cn/crates.io-index/"
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index/"

rustup

  • rustup是rust官方提供的rust工具链管理命令;
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 查看已安装的rust 工具链
$ rustup show

$ rustup default stable-

## 升级rustup
$ rustup update
## 显示rustup组件列表
$ rustup component list
## 安装cargo组件
$ rustup componenet add cargo

Cargo

参考

  1. https://www.jianshu.com/p/64d54d39cffb
  2. https://blog.csdn.net/wowotuo/article/details/76375395
  3. https://lotabout.me/2016/rust-lifetime/
updatedupdated2024-08-252024-08-25