(1). 概述
这几个月一直没有更新技术,原因:6月底从一家跨境电商离职,7月和几个同事一起走了一遍新疆,8月份开始技术顾问的工作,稍微有一点点闲时间,才静下来更新技术文章.
Rust是一个同事的推荐,原因是:他完成切换到了Rust开发(好像近来也比较热门),怀着好奇的心情,开始地Rust进行一个简单的学习.
(2). Rust安装
lixin-macbook:~ lixin$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:
/Users/lixin/.rustup
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory is located at:
/Users/lixin/.cargo
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
/Users/lixin/.cargo/bin
This path will then be added to your PATH environment variable by
modifying the profile files located at:
/Users/lixin/.profile
/Users/lixin/.bash_profile
/Users/lixin/.zshenv
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Current installation options:
default host triple: x86_64-apple-darwin
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
# 选择自定义安装
# ********************************************************************
>1
info: profile set to 'default'
info: default host triple is x86_64-apple-darwin
warning: Updating existing toolchain, profile choice will be ignored
info: syncing channel updates for 'stable-x86_64-apple-darwin'
703.5 KiB / 703.5 KiB (100 %) 351.7 KiB/s in 2s ETA: 0s
info: latest update on 2022-08-11, rust version 1.63.0 (4b91a6ea7 2022-08-08)
info: downloading component 'cargo'
4.7 MiB / 4.7 MiB (100 %) 1.4 MiB/s in 2s ETA: 0s
info: downloading component 'clippy'
info: downloading component 'rust-docs'
18.4 MiB / 18.4 MiB (100 %) 2.8 MiB/s in 8s ETA: 0s
info: downloading component 'rust-std'
24.8 MiB / 24.8 MiB (100 %) 2.3 MiB/s in 11s ETA: 0s
info: downloading component 'rustc'
52.8 MiB / 52.8 MiB (100 %) 3.4 MiB/s in 22s ETA: 0s
info: downloading component 'rustfmt'
2.5 MiB / 2.5 MiB (100 %) 1.1 MiB/s in 1s ETA: 0s
info: removing previous version of component 'cargo'
info: removing previous version of component 'clippy'
info: removing previous version of component 'rust-docs'
info: removing previous version of component 'rust-std'
info: removing previous version of component 'rustc'
info: removing previous version of component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
18.4 MiB / 18.4 MiB (100 %) 2.5 MiB/s in 5s ETA: 0s
info: installing component 'rust-std'
24.8 MiB / 24.8 MiB (100 %) 11.6 MiB/s in 2s ETA: 0s
info: installing component 'rustc'
52.8 MiB / 52.8 MiB (100 %) 12.3 MiB/s in 4s ETA: 0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-apple-darwin'
stable-x86_64-apple-darwin updated - rustc 1.63.0 (4b91a6ea7 2022-08-08) (from rustc 1.62.1 (e092d0b6b 2022-07-16))
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, run:
# 重启或者运行环境生效
# ********************************************************************
source "$HOME/.cargo/env"
(3). 检查Rust安装情况
lixin-macbook:~ lixin$ rustc -V
rustc 1.63.0 (4b91a6ea7 2022-08-08)
# cargo相当于java下的maven
lixin-macbook:~ lixin$ cargo -V
cargo 1.63.0 (fd9c4297c 2022-07-01)