Idea 如何使用 Rust 开发环境?

原创
03/02 17:54
阅读数 257

依次打开文件-设置-语言和框架- Rust 。本机配置完成如图所示

首先下载 Rust 安装包。中文下载地址

切换到安装文件目录。

PS C:\Windows\system32> cd C:\Users\lenovo\Downloads
PS C:\Users\lenovo\Downloads>

开始安装,本机输入1开始安装。期间会提示是否添加环境变量等,推荐 y 。

PS C:\Users\lenovo\Downloads> .\rustup-init.exe

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:

  C:\Users\lenovo\.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  C:\Users\lenovo\.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:

  C:\Users\lenovo\.cargo\bin

This path will then be added to your PATH environment variable by
modifying the HKEY_CURRENT_USER/Environment/PATH registry key.

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-pc-windows-msvc
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>

回车以后界面如图所示,安装类似显示如下

PS C:\Users\lenovo\Downloads> .\rustup-init.exe

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:

  C:\Users\lenovo\.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  C:\Users\lenovo\.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:

  C:\Users\lenovo\.cargo\bin

This path will then be added to your PATH environment variable by
modifying the HKEY_CURRENT_USER/Environment/PATH registry key.

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-pc-windows-msvc
     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-pc-windows-msvc
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
676.1 KiB / 676.1 KiB (100 %) 367.0 KiB/s in  1s ETA:  0s
info: latest update on 2021-02-11, rust version 1.50.0 (cb75ad5db 2021-02-10)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 14.6 MiB /  14.6 MiB (100 %)   4.7 MiB/s in  3s ETA:  0s
info: downloading component 'rust-std'
 20.9 MiB /  20.9 MiB (100 %)   4.7 MiB/s in  5s ETA:  0s
info: downloading component 'rustc'
 52.1 MiB /  52.1 MiB (100 %)   5.4 MiB/s in 12s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: using up to 500.0 MiB of RAM to unpack components
info: installing component 'clippy'
info: installing component 'rust-docs'
 14.6 MiB /  14.6 MiB (100 %)   2.8 MiB/s in  4s ETA:  0s
info: installing component 'rust-std'
 20.9 MiB /  20.9 MiB (100 %)  12.3 MiB/s in  8s ETA:  0s
info: installing component 'rustc'
 52.1 MiB /  52.1 MiB (100 %)  13.9 MiB/s in  3s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-pc-windows-msvc'

  stable-x86_64-pc-windows-msvc installed - rustc 1.50.0 (cb75ad5db 2021-02-10)


Rust is installed now. Great!

To get started you need Cargo's bin directory (%USERPROFILE%\.cargo\bin) in
your PATH environment variable. Future applications will automatically
have the correct environment, but you may need to restart your current shell.

Press the Enter key to continue.

PS C:\Users\lenovo\Downloads>

等待组件下载完成, Enter 安装完成后重新打开 idea 即可自动识别,效果见图1。

后记:Windows x86_64 离线安装文件下载地址:https://static.rust-lang.org/dist/rust-1.50.0-x86_64-pc-windows-msvc.msi 。文档地址: https://forge.rust-lang.org/infra/other-installation-methods.html#standalone-installers 。

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部