Rust基本使用

install rust

1
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

or

1
2
3
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
curl --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh

set registry

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
cat <<EOF | tee -a ~/.cargo/config
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true
EOF

update

1
rustup update
updatedupdated2024-08-182024-08-18