rust学习 1、Hello World

rustup镜像

修改 $HOME/.bashrc 添加

export PATH=/$HOME/.cargo/bin:$PATH
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static             # 用于更新toolchain
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup      # 用于更新rustup

安装

安装rustup

curl https://sh.rustup.rs -sSf | sed "s@\(RUSTUP_UPDATE_ROOT=\).*@\1$RUSTUP_UPDATE_ROOT@" | sh

通过rustup安装rust

rustup update stable

crates镜像

修改 $HOME/.cargo/config

[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

hello world

$ cargo new --bin hello_world       
     Created binary (application) `hello_world` project
$ cd hello_world/
$ cargo run
   Compiling hello_world v0.1.0 (file:///mnt/storage/home/rust_test/hello_world)
    Finished dev [unoptimized + debuginfo] target(s) in 0.33 secs
     Running `target/debug/hello_world`
Hello, world!

发表评论

电子邮件地址不会被公开。 必填项已用*标注