This is the first day of my participation in Gwen Challenge

Rust is a language that empowers everyone to build reliable and efficient software.

What is a Rust

Rust is a language that empowers everyone to build reliable and efficient software. It has no runtime and garbage collection, and is extremely memory efficient. So it has very high performance; Because Javascript is a weakly typed language, Typescript has become very popular to compensate for this problem. The recent introduction of static type checking in Python and Rust illustrates the fact that type constraints are an unfetchable part of developing applications, so Rust’s rich type system and ownership model ensures memory safety and thread-safety, allowing you to eliminate all manner of errors at compile time. And Rust’s technology ecosystem is complete.

Why does the front end learn Rust

Because front-end technology updates so quickly, a lot of technology is written in Rust. Deno, for example, was originally written in Go, then abandoned go altogether and switched to Rust. The core reason is that Go is also an automatic garbage collection language, which causes a certain amount of performance consumption, while Rust has no garbage collection, so Rust has a huge advantage in performance. For example, WebAssembly, when handling large amounts of data or complex calculations, use Rust to enhance your JavaScript modules one by one. Publish to NPM, package with Webpack, and experience an amazing speed increase. Wait…

Environment to prepare

First you have to have a Mac or A Windows computer, not Linux.

Mac installation

Open the terminal and enter the command

curl --proto '=https'- tlsv1.2 https://sh.rustup.rs - sSf | shCopy the code

Wait a few minutes and the 👇 prompt appears:

Rust is installed now. Great!
Copy the code

You can then check whether Rust installed successfully:

Rustc --version or ruSTC -v RUSTC X.Y.Z (ABcabcabc YYYY-MM-DD)Copy the code

Windows installation

Window download address double-click to install, automatically inject path.

update

To upgrade to the latest version of Rust, run rustup:

rustup update
Copy the code

uninstall

Open a terminal and enter the following command to uninstall Rust and Rustup

rustup self uninstall
Copy the code

Editor preparation

To do a good job, he must sharpen his tools. The editor is chosen according to personal preference.

Vim Rust plugin: rust.vim

The Vim plugin rust.vim is implemented by Rust and can be used by fidgeting developers to configure the Rust development environment under Vim. Rust. vim provides rust file detection, syntax highlighting, formatting and Syntastic integration with the syntax detection tool. Features include:

  • Syntastic error detection: Rust. vim automatically registers Cargo with Syntastic as a syntax checker by default.

You can integrate Tagbar to view the source code

  • Rustfmt formatting code: With Rustfmt installed, you can use the: rustfmt command to format code.
  • The Playpen integration: :RustPlay command sends the current selection to Rust Playpen, or the current buffer to Rust Playpen if nothing is selected.
  • Test: In a Cargo project, the :RustTest command runs the test in real time.

The Rust plug-in provided by Visual Studio Code

Vscode also provides the Rust plug-in. Search for Rust in the extension store. The plugin also supports:

  • Code completion
  • Jump to definition, PEEK Definition, find all References and symbol Search
  • Type and document hover hints
  • Code formatting
  • refactoring
  • Correct errors and apply recommendations
  • snippets
  • Build tasks

At the end

Next section: Rust from Entry to Run – Part 2 Hello Word