Rust Preliminary (ii): Writing rust programs using Visual Studio code (guess the game)

Source: Internet
Author: User

I followed this help document to complete the first complete rust program: Guess the game

Http://kaisery.gitbooks.io/rust-book-chinese/content/content/3.1.Guessing%20Game%20%E7%8C%9C%E7%8C%9C%E7%9C%8B.html

The development tool I'm using is Visual Studio Code, which should be the most WYSIWYG editor I can find today, especially for our heavy Windows-dependent patients.

But what needs to be put forward is that I was developing visual Studio code that was installed in Ubuntu. Thanks to Microsoft's efforts for more than a year, Visual studio officially supports different platforms such as Windows,linux,mac.

Visual Studio code is still in the improvement, I hope it will be more convenient later

The effect of running is as follows

It should be noted that the rust program does not require runtime, that is, only on the development of the machine need to install rust and related tools (in fact, mainly three tools RUSTC, cargo, Rustdoc), on the target running machine, can be directly run. The Cargo build command allows us to generate the binary code files we need

In fact, we just need to copy the Guessing_game executable file to the other machine to run it directly.

However, it is important to note that the executable files of different platforms need to be compiled on the corresponding platform. In other words, the rust program compiled in Linux can only be run in Linux. It doesn't look perfect, does it? Can't you really achieve "write once, run everywhere"? But in fact this problem is easy to solve, if you need to compile on the Windows platform, only need to download the code, run the appropriate compilation command.

For example, I do this guessing game, the code is uploaded to the

Https://github.com/chenxizhang/rust_training

You can download the code with the Git tool

Then, in Windows, you can simply run the following commands to compile and run

Cargo build

Cargo run

It is important to note that the current Windows XP and the following versions are not supported by Rust compiled programs (at least a variety of problems), try to run the above compiled program will encounter the following error

Rust Preliminary (ii): Writing rust programs using Visual Studio code (guess the game)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.