Rust basic learning-01-install rust

Time:2022-5-19

Original text fromhttps://solleter.me

About the introduction of rust, there is no more description here. There is a lot of information on the network. Here, let’s start directly. This series of blogs is learningRust programming language simplified Chinese versionSome notes in the process. There are many places, but also refer to the official English version.

There is no standard answer to whether I should learn rust. For me, I mainly want to accumulate some experience in compiled system level language, because I only know C + + and can probably understand it, which is far from reaching the level of proficient code, but I don’t want to learn C + +, so I chose rust.

Before installation, there are a few things to understand

  • RustupIt is used to install, update and manage different platform versions of rust
  • RustVersion hasStableNightly, some new features are usually in nightly version. After stabilization, they may be added to stable officially. Generally, we can use stable version
  • toolchainHere, we simply understand it as a rust version
  • On windows, you will find that even the stable version will havegnuandmsvcEither version can be used at present. MSVC is used on windows by default. Just keep the default here
  • cargoUsed to organize rust projects, such as creating projects, building projects, testing projects, etc.

Download and install rustup

visithttps://www.rust-lang.org/zh-CN/tools/install, if it is under Windows system, download itRUSTUP-INIT.EXE, if it is OSX or Linux, use its script to downloadcurl https://sh.rustup.rs -sSf | sh

Install rust

Download goodrustupAfter running, it should run automatically under OSX or Linux. After running, the following interface will appear
Rust basic learning-01-install rust
Just keep the default here. Enter1Then press enter to install. You can see here that the default installation isstable msvcVersionrust。 Here will be automatically downloaded, installed and then set.

Rust basic learning-01-install rust
Here, when you see this interface, it means that it has been downloaded and installed and can be used.

View and modify configuration

  1. rustc --versionView rustc version
  2. cargo --versionView cargo version
  3. rustup toolchain listLists the currently installed version of trust, (default) is the currently used version
  4. rustup default stable-x86_64-pc-windows-msvc
    Set the version of trust using stable MSVC (which can be abbreviated as stable MSVC)
  5. rustup default stable-x86_64-pc-windows-gnu
    Set the version of trust using stable GNU (which can be abbreviated as stable GNU)

Start using the next articlecargoCreate a project and start writing code

Rust basic learning-01-install rust