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

Cargo and crates

When projects get large, a usual practice is to refactor code into smaller, more manageable units as modules or libraries. You also need tools to render documentation for your project, how it should be built, and what libraries it depends on. Furthermore, to support the language ecosystem where developers can share their libraries with the community, an online registry of some sort is often the norm these days.

Cargo is the tool that empowers you to do all these things, and https://crates.io is the centralized place for hosting libraries. A library written in Rust is called a crate, and crates.io hosts them for developers to use. Usually, a crate can come from three sources: a local directory, an online Git repository like GitHub, or a hosted crate registry like crates.io. Cargo supports crates from all of these sources.

Let's see Cargo in action. If you ran rustup, as described in the previous chapter, you will already have cargo installed, along with rustc. To see what commands are available to us, we can run cargo without any parameters:

It shows a list of common commands that we can use, along with some flags. Let's use the the new subcommand to create a new Cargo project.

主站蜘蛛池模板: 镇康县| 嘉善县| 龙江县| 叙永县| 常山县| 莱州市| 会昌县| 宣武区| 碌曲县| 安化县| 上虞市| 陇川县| 偃师市| 通化市| 顺平县| 新龙县| 衡阳县| 北川| 沙洋县| 化隆| 五莲县| 巴南区| 石城县| 乐昌市| 凯里市| 康马县| 延长县| 镇原县| 临猗县| 抚远县| 科技| 忻州市| 托克逊县| 康定县| 玉环县| 游戏| 达拉特旗| 林芝县| 浠水县| 安泽县| 仲巴县|