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

  • Learning Rust
  • Paul Johnson Vesa Kaihlavirta
  • 222字
  • 2021-07-02 23:07:13

Cleaning your source tree with Cargo

When the Rust compiler compiles the source files, it generates something known as an object file. The object file takes the source file (which we can read and understand) and compiles this into a form that can be joined with other libraries to create a binary.

This is a good idea, as it cuts down on compilation time; if a source file has not been changed, there is no need to recompile the file, as the object file will be the same.

Sometimes, the object file becomes out of date, or code in another object file causes a panic due to conflicts. In this case, it is not uncommon to "clean" the build. This removes the object files, and the compiler then has to recompile all the source files.

Also, it should always be performed prior to creating a release build.

The standard Unix make program performs this with the clean command (make clean). Cargo performs the clean operation in a way similar to the make utility in Unix:

cargo clean  

A comparison of the directories shows what happens when using the preceding Cargo command:

The entire target directory structure has simply been removed (the preceding screenshot was from a Mac, hence the dSYM and plist files. These do not exist on Linux and Windows).

主站蜘蛛池模板: 察雅县| 中超| 额敏县| 谷城县| 合川市| 九龙县| 金堂县| 兴业县| 和顺县| 潼关县| 临朐县| 衡阳县| 平度市| 舞钢市| 葫芦岛市| 阜南县| 嘉善县| 五原县| 襄汾县| 临泽县| 苍溪县| 九龙县| 南澳县| 福鼎市| 治多县| 泰安市| 子洲县| 垣曲县| 集贤县| 桑日县| 辛集市| 兴国县| 桃源县| 博野县| 滨海县| 武城县| 兰坪| 广饶县| 乌兰察布市| 营山县| 定安县|