- Mastering Rust
- Rahul Sharma Vesa Kaihlavirta
- 208字
- 2021-07-02 13:35:19
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.
- 零基礎(chǔ)搭建量化投資系統(tǒng):以Python為工具
- PostgreSQL Cookbook
- Python爬蟲開發(fā):從入門到實(shí)戰(zhàn)(微課版)
- Developing Middleware in Java EE 8
- Blockly創(chuàng)意趣味編程
- The Complete Coding Interview Guide in Java
- BIM概論及Revit精講
- C# and .NET Core Test Driven Development
- HoloLens與混合現(xiàn)實(shí)開發(fā)
- Python Data Science Cookbook
- 機(jī)器學(xué)習(xí)微積分一本通(Python版)
- Tableau Desktop可視化高級(jí)應(yīng)用
- Learning Concurrency in Python
- INSTANT Apache Hive Essentials How-to
- Python Django Web從入門到項(xiàng)目實(shí)戰(zhàn)(視頻版)