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)