hello world
1. 安装环境
linux / wsl curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
gcc sudo apt install build-essential
替换源 :
cd ~/.cargo
code config
#这里使用vscode创建文件并编辑
# 放到 `$HOME/.cargo/config` 文件中
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 替换成你偏好的镜像源
replace-with = 'sjtu'
#replace-with = 'ustc'
# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# 中国科学技术大学
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
# rustcc社区
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"
2.创建项目并运行
cargo new hello-world
cd hello-world
cargo run