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

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

主站蜘蛛池模板: 泾阳县| 勐海县| 湖口县| 永胜县| 安庆市| 岳阳市| 镇平县| 比如县| 新巴尔虎右旗| 巩留县| 运城市| 桐城市| 克东县| 太仆寺旗| 达拉特旗| 鸡泽县| 同心县| 吉隆县| 永福县| 广东省| 鹰潭市| 崇阳县| 威海市| 乐陵市| 崇文区| 达州市| 吉首市| 集贤县| 西充县| 林州市| 措美县| 徐州市| 遵化市| 合江县| 依安县| 惠东县| 巩义市| 泸溪县| 武威市| 鹰潭市| 新郑市|