Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of developing Rust with DE in 2021

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "what is the method of developing Rust with DE in 2021". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Rust language server: Rust Language Server

Rust language server (RLS) is based on LSP (Language Server Protocol), that is, language server protocol. LSP is jointly launched by Red Hat, Microsoft and Codenvy, which allows different program editors and integrated development environments (IDE) to easily embed various programming languages, allowing developers to write programs in various languages in their favorite tools.

Through the JSON-RPC standard for communication between development tools and language servers, it enables programming tools to provide detailed information of real-time feedback and achieve a variety of powerful functions, such as symbol search, syntax analysis, code automatic completion, moving to definition, outline and refactoring, etc. The Rust language server integrates this logic as the back-end and provides it to the front-end tools through the standard LSP. It is designed to be independent of the front-end and can be widely adopted by different editors and IDE, but currently the project team is only testing in VS Code. Users can find the official Rust plug-in based on RLS implementation in the VS Code extension Store.

This is the Rust plug-in officially provided by Rust for Visual Studio Code, which was originally the front-end reference implementation of Rust official language Server (RSL). Now it also supports another Rust server rust-analyzer (RA) maintained by the community. Users can choose to install one between RSL or RA according to their personal preferences. The plug-in supports:

Code completion

Jump to definition, peek definition, find all references and symbol search

Type and document hover hint

Code formatting

Reconstruct

Correct errors and apply recommendations

Snippets

Build task

Two features worth mentioning are snippets (code snippets) and build tasks.

Snippets is a code template that extends to a generic template. When you enter, Intellisense includes the code snippet name as an option, which can be selected by shortcut keys. The following snippets is provided:

For-create a loop

Unimplemented

Unreachable

Print (ln)

Assert (_ eq)

Macro_rules-declare macros

If let Option-execute if let statements in some cases

Spawn-create thread

Extern crate-insert extern crate statement

This Rust plug-in provides tasks for building, running, and testing using related cargo commands, which can be built using ctrl + shift + b, and other tasks can be viewed through "run tasks" in the command panel. The contents of these tasks are written in task.json, and the plug-in does not overwrite existing tasks, so you can customize them.

Community-driven Rust language server rust-analyzer

Rust-anlyzer (RA) is another Rust language server in addition to RSL, which is community-driven. Since the release of the first precompiled Release at the end of 2019, RA has steadily released new versions every Tuesday and has maintained them ever since. After rapid iteration, the optimization and improvement of all aspects of RA has surpassed RSL, so it has been officially included as part of the RSL 2.0 plan. Rust's official VS Code plug-in has also added support for RA.

RA currently supports editors such as Vim, Emac, Sublime Text 3, and VSCode, and detailed installation instructions are available through the official documentation.

Rust code completion program: Racer

As mentioned earlier, RSL and RA are both Rust language servers that provide common capabilities as the back end of IDE and editors. Racer is a static library in the Rust language server, which provides automatic code completion.

Many tools such as IDE can easily integrate such low-level functions. Currently, the following tools all have related implementations for integrating Racer:

Eclipse

Emacs

Gedit

Gnome Builder

Kate

Sublime Text

Vim

VS Code

Atom

Kakoune

Rust plug-ins for IntelliJ: IntelliJ Rust and intellij-toml

IntelliJ Rust is a Rust plug-in for IntelliJ and is developed in Kotlin. Its features include:

Support native code hints

Support for powerful keyboard shortcuts

Quick formatting of code

Snippets

IntelliJ Rust and intellij-toml bring Rust and TOML support to IDEA,CLion,PyCharm and other JetBrains IDE.

Language support includes syntax highlighting, completion, navigation and other code insight functions. You can use the Cargo command and run Clippy or Rustfmt without leaving IDE. Debuggers and parsers are provided in CLion and IntelliJ IDEA Ultimate. The integration of CLion also supports CPU analysis. For all other IDE, you can use the native debugging plug-in for debugging.

CLion + cross-platform integrated development environment

CLion is an IDE dedicated to the development of CumberCandle +, and its features include:

Smart CamePack + Editor: native Cpicket + support, including modern C++ standard, libc++ and Boost.

Navigation capabilities: instantly navigate to the declaration or contextual usage of characters, search for classes, files, and characters by name throughout the project, and provide a code base with structural and hierarchical views.

Code generation: some code generation operations can be completed through simple keyboard shortcuts, including: adding class members, rewriting / implementing functions, generating constructors / destructors, getter/setter, judging equality, relational operations and stream output operations, using statements to encapsulate code blocks and generating declarations according to actual usage.

Refactoring: provides functions such as renaming symbols, moving members up / down in the hierarchy, and changing function signatures.

Through the IntelliJ Rust plug-in, CLion provides high support for Rust. In addition to basic functions, it also provides Rust with complete debugger, CPU Profiler, and Valgrind memory checking capabilities.

Rust plug-in for Eclipse IDE: Eclipse Corrosion

This is the end of the content of "what is the method of developing Rust with DE in 2021". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report