官术网_书友最值得收藏!

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).

主站蜘蛛池模板: 滨海县| 惠水县| 外汇| 鄂托克前旗| 石景山区| 稷山县| 罗源县| 富裕县| 句容市| 潮安县| 静宁县| 诏安县| 乐山市| 木兰县| 双流县| 万山特区| 青河县| 凤翔县| 前郭尔| 鄄城县| 舞钢市| 喀喇| 天门市| 明水县| 嵊泗县| 将乐县| 碌曲县| 三台县| 新乡市| 集安市| 加查县| 四川省| 同德县| 太康县| 遵化市| 方正县| 从江县| 鲜城| 乌兰察布市| 冀州市| 乌兰浩特市|