- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 172字
- 2021-07-02 23:07:13
Using Cargo to build and run an application
As we are all able to create directory structures, Cargo is then able to build and execute our source code.
If you look at the source code that comes with this chapter, you will find a directory called app_name. To build this package using Cargo, type the following from a Terminal (or command on Windows) window:
cd app_name cargo build app_name
This will build the source code; finally you will be informed that the compilation has been successful:

Next, we can use Cargo to execute the binary as follows:
cargo run
If everything has worked, you will see something like the following:

As with any sort of utility, it's possible to "daisy-chain" the build and execution into one line, as follows:
cargo build; cargo run
You may be wondering why the first operation performed was to move into the application structure rather than just type cargo build. This is because Cargo is looking for the Cargo.toml file (remember, this acts as a build script).
- JBoss Weld CDI for Java Platform
- Spring Boot開發與測試實戰
- 程序設計與實踐(VB.NET)
- Web Scraping with Python
- 數據結構(Python語言描述)(第2版)
- 精通Scrapy網絡爬蟲
- Internet of Things with Intel Galileo
- Unity Shader入門精要
- C程序設計實踐教程
- HTML 5與CSS 3權威指南(第3版·上冊)
- Qlik Sense? Cookbook
- Visual Basic程序設計(第三版)
- UI設計基礎培訓教程(全彩版)
- Backbone.js Patterns and Best Practices
- IBM DB2 9.7 Advanced Application Developer Cookbook