Hands-On Data Structures and Algorithms with Rust
上QQ阅读APP看书,第一时间看更新

Cargo and Crates

Rust is a rather young language that has been designed from scratch to be a practical and useful tool for programmers. This is a great situation to be in: there are no legacy applications to care about, and many lessons learned from other languages have been incorporated in Rust—especially around tooling.

Integrating and managing third-party packages has been an issue in the past for a lot of languages, and there are a few different approaches out there:

  • NPM: The package manager for Node, which has been very popular with the JavaScript community
  • Maven: Enterprise-grade Java package management, based on the XML format
  • NuGet: .NET's package management
  • PyPI: The Python package index

Each of these has different styles of configuration, naming guidelines, publishing infrastructure, features, plugins, and so on. The Rust team learned from all of these approaches and built their own version: cargo. This chapter will be all about the power of cargo of how and where to integrate with the wealth of packages (called crates) out there. Whether you are working on your own small library or you are building a large enterprise-grade system, cargo will be a central piece of the project. By reading this chapter, you can look forward to the following:

  • Learning more about cargo, its configuration, and plugins
  • Knowing more about the different types of crates
  • Benchmarking and test integration done in cargo