Idea 如何使用 Rust 開發環境?

依次打開文件-設置-語言和框架- 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 。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章