Use IntelliJ as the rust IDE

Time:2021-10-14

RustIt is a general compiled language developed by Mozilla. Its design criterion is “safe, concurrent and practical”, and supports functional, parallel, procedural and object-oriented programming styles.
IntelliJ is one of the best used java ides. It supports a variety of plug-ins, includingintellij-rustnamelyRustFor the plug-in on IntelliJ, you can use the plug-in to develop rust on IntelliJ. Here is a brief introduction to how to install rust and use IntelliJ as its ide.

Install rust

When installing rust, do not directly use the rust language itself, for examplebrew install rustJust install the trust language itself. What should be installed isrustup,rustupIt is the management tool of the official version of trust and the first choice for installing trust. Its main features are:

  1. Manage rust binaries
  2. Configure rust tool chain
  3. Manage rust related components
  4. Rely only on bash, curl, and common UNIX tools
  5. Support multi platform

The tools often used in the development process of using rust arerustc,rust-src,cargo, these can be managed using rustup.
amongcargoIt is a tool for rust project management and provides a series of tools, from project establishment, construction to testing, operation to deployment, which provide the means to complete the management of rust project as much as possible.
rustcIs a compiler for the trust language.
rust-srcIs the trust standard library.

Install rustup:

curl https://sh.rustup.rs -sSf | sh

During the installation process, you will be asked to select the installation method. You can install it by defaultcargo。 After installation, you need to set two directories into the path variable:

  • $home /. Cargo / bin, bin directory of cargo
  • $home /. Cargo / Env, directory configured for shell

adoptrustup helpYou can see the relevant commands of rustup. The above default does not include componentsrust-srcInstallation of requires separate installation of componentsrust-src:

rustup component add rust-src

In this way, the environment installation of rust has been completed. The components to be used in the IDE using IntelliJ as rust include:rustc,cargoandrust-src

Installing the IntelliJ plug-in

Two plug-ins need to be installedintellij-rustandintellij-toml, intellij-rustIt’s a rust language plug-in,intellij-tomlIt is a plug-in for the toml language and is used for the cargo configuration file cargo.toml.
Installation method:Perferences.. -> Plugins Search rust directly in the marketplace

Search in the same waytomlAnd install.
After installing the plug-in, you can create a new project and select rust:

You can see that the toolchain location is the configured $home /. Cargo / bin, and the standard library is installed beforerust-srcDirectory of.
After the project is created successfully, you can see a complete trust project:

quote
  1. Wikipedia:https://zh.wikipedia.org/wiki…
  2. Rust lang: https://www.rust-lang.org/
  3. intellij-rust :https://github.com/intellij-r…
  4. intellij-tom :https://github.com/intellij-r…

Recommended Today

Pandas from introduction to mastery (1) – Basics

We all know that Python can occupy a place in the field of data science, mainly due to the three swordsmen of data analysis: numpy, pandas and Matplotlib. Among the three libraries, I think pandas is the core and most used. Whether dealing with data or playing games, it is required to be able to […]