首先执行
% brew install rustup-init
然后执行
% rustup-init
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/lester/.rustup
/Users/lester/.profile
/Users/lester/.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
此时可以选择自己需要安装的版本,我选的是nightly
nightly-x86_64-apple-darwin installed - rustc 1.66.0-nightly (c0983a9aa 2022-10-12)
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"
设置环境后可以用命令看安装情况
% source "$HOME/.cargo/env"
% rustup show
Default host: x86_64-apple-darwin
rustup home: /Users/lester/.rustup
nightly-x86_64-apple-darwin (default)
% rustc --version
rustc 1.66.0-nightly (c0983a9aa 2022-10-12)
% cargo --version
cargo 1.66.0-nightly (b8f30cb23 2022-10-10)
2. IntelliJ IDEA 安装 rust 支持
先安装IntelliJ IDEA 然后 安装rust 插件
然后 重启后 新建项目选择 左边最下方的 rust 选项,就可以了