- 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.
- C++案例趣學
- Spring 5企業級開發實戰
- Software Defined Networking with OpenFlow
- Vue.js 2 and Bootstrap 4 Web Development
- Mastering Business Intelligence with MicroStrategy
- MongoDB,Express,Angular,and Node.js Fundamentals
- C#程序設計(項目教學版)
- Orleans:構建高性能分布式Actor服務
- Android應用開發攻略
- 計算思維與Python編程
- Python編程基礎
- 面向WebAssembly編程:應用開發方法與實踐
- Kubernetes進階實戰(第2版)
- 架構寶典
- Java Coding Problems