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

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.

主站蜘蛛池模板: 稻城县| 连州市| 天长市| 青河县| 阳山县| 漾濞| 喜德县| 大姚县| 印江| 灌阳县| 广河县| 河间市| 根河市| 浑源县| 西青区| 阿勒泰市| 邯郸市| 增城市| 芦溪县| 马公市| 竹北市| 甘泉县| 南川市| 祁门县| 观塘区| 南平市| 正定县| 卢氏县| 禄劝| 宣恩县| 佳木斯市| 秦皇岛市| 长治市| 十堰市| 怀柔区| 秭归县| 班戈县| 蛟河市| 洞口县| 南木林县| 嘉善县|