Rust Must-Know Crates
Tags: rust, awesomelist, libraries, list
Published: 2019-05-07 21:24:53

---
title: Rust Must-Know Crates
published: true
description: 35+ Rust Crates You Will Want to Know About
tags: Rust,awesome-list,libraries,list
---

This is my collection of Rust crates that I often find myself using. Not every project needs to use all of them, but most projects are better off knowing that they exist. Crates are _very_ loosely ordered within their heading from more generally useful to more niche application.

This list will be kept somewhat up to date as my preferences and the ecosystem shift. This is obviously not a complete list of great crates, but just an introduction to the great ecosystem of Rust utilities available to programmers.

# Cargo Plugins

## [cargo-edit](https://lib.rs/crates/cargo-edit)

> This tool extends Cargo to allow you to add, remove, and upgrade dependencies by modifying your Cargo.toml file from the command line.
> 
> Currently available subcommands:
> 
> - cargo add
> - cargo rm
> - cargo upgrade

## [cargo-outdated](https://lib.rs/crates/cargo-outdated)

> A cargo subcommand for displaying when Rust dependencies are out of date.

## [cargo-tree](https://lib.rs/crates/cargo-tree)

> A Cargo subcommand that visualizes a crate's dependency graph in a tree-like format.

## [cargo-update](https://lib.rs/crates/cargo-update)

> A Cargo subcommand for checking and applying updates to installed executables.

## [cargo-expand](https://lib.rs/crates/cargo-expand)

> Print out the result of macro expansion and `#[derive]` expansion applied to the current crate.

## [cargo-modules](https://lib.rs/crates/cargo-modules)

> A cargo plugin for showing an overview of a crate's modules.

## [cargo-tarpaulin](https://lib.rs/crates/cargo-tarpaulin)

> Tarpaulin is designed to be a code coverage reporting tool for the Cargo build system, named for a waterproof cloth used to cover cargo on a ship. Currently, tarpaulin provides working line coverage but is still in the early development stage and therefore may contain some bugs.

## [cargo-audit](https://crates.io/crates/cargo-audit)

> Audit Cargo.lock for crates with security vulnerabilities reported to the RustSec Advisory Database.

## [cargo-crev](https://lib.rs/crates/cargo-crev)

> A tool helping Rust users review crates they use, and share it with the community. It works as a recomendation system, helps identify poor quality, protects against many attack vectors, and aims at driving the quality of Rust ecosystem even higher, by encouraging continous peer review culture.

## [cargo-clone](https://lib.rs/crates/cargo-clone)

> Fetch the source code of a Rust crate.

`cargo clone` will likely be added to cargo proper at some point.

# Derives

## [derive-more](https://lib.rs/crates/derive_more)

> Rust has lots of builtin traits that are implemented for its basic types, such as `Add`, `Not` or `From`. However, when wrapping these types inside your own structs or enums you lose the implementations of these traits and are required to recreate them. This is especially annoying when your own structures are very simple, such as when using the commonly advised newtype pattern (e.g. `MyInt(i32)`).
> 
> This library tries to remove these annoyances and the corresponding boilerplate code. It does this by allowing you to derive lots of commonly used traits for both structs and enums.

Derives for:

- [`From`](https://jeltef.github.io/derive_more/derive_more/from.html)
- [`Into`](https://jeltef.github.io/derive_more/derive_more/into.html)
- [`FromStr`](https://jeltef.github.io/derive_more/derive_more/from_str.html)
- [`TryInto`](https://jeltef.github.io/derive_more/derive_more/try_into.html)
- [`Display`-like](https://jeltef.github.io/derive_more/derive_more/display.html)
- [`Index`](https://jeltef.github.io/derive_more/derive_more/index_op.html)([`Mut`](https://jeltef.github.io/derive_more/derive_more/index_mut.html))
- [`Deref`](https://jeltef.github.io/derive_more/derive_more/deref.html)([`Mut`](https://jeltef.github.io/derive_more/derive_more/deref_mut.html))
- [`Add`](https://jeltef.github.io/derive_more/derive_more/add.html)([`Assign`](https://jeltef.github.io/derive_more/derive_more/add_assign.html))
- [`Mul`](https://jeltef.github.io/derive_more/derive_more/mul.html)([`Assign`](https://jeltef.github.io/derive_more/derive_more/mul_assign.html))
- [`Not`](https://jeltef.github.io/derive_more/derive_more/not.html)
- and more!

## [smart-default](https://lib.rs/crates/smart-default)

> Custom derive for automatically implementing the `Default` trait with customized default values.

## [derive-builder](https://lib.rs/crates/derive_builder)

> Rust macro to automatically implement the builder pattern for arbitrary structs. A simple `#[derive(Builder)]` will generate a `FooBuilder` for your struct `Foo` with all setter-methods and a build method.

## [strum](https://lib.rs/crates/strum)

> A set of macros and traits for working with enums and strings easier in Rust.

Derives for:

- [`Display`](https://github.com/Peternator7/strum#Display)
- [`AsRefStr`](https://github.com/Peternator7/strum#AsRefStr)
- [`IntoStaticStr`](https://github.com/Peternator7/strum#IntoStaticStr)
- [`EnumIter`](https://github.com/Peternator7/strum#enumiter)
- [`EnumCount`](https://github.com/Peternator7/strum#enumcount)
- and more!

# Meta-programming (macros)

## [syn](https://lib.rs/crates/syn)

> Syn is a parsing library for parsing a stream of Rust tokens into a syntax tree of Rust source code.

## [proc-macro2](https://libs.rs/crates/proc_macro2)

> A runtime-compatible wrapper around the procedural macro API of the compiler's `proc_macro` crate.

## [proc-quote](https://lib.rs/crates/proc-quote)

> The `quote!` macro as a procedural macro, instead of the original `quote!` macro, implemented with `macro_rules!`.
> 
> The `quote!` macro turns Rust syntax tree data structures into tokens of source code.

## [paste](https://lib.rs/crates/paste)

> A flexible way to paste together identifiers in a macro, including using pasted identifiers to define new items.

# Testing

## [insta](https://lib.rs/crates/insta)

> Snapshots tests (also sometimes called approval tests) are tests that assert values against a reference value (the snapshot). This is similar to how `assert_eq!` lets you compare a value against a reference value but unlike simple string assertions snapshot tests let you test against complex values and come with comprehensive tools to review changes.

## [trybuild](https://lib.rs/crates/trybuild)

> Trybuild is a test harness for invoking rustc on a set of test cases and asserting that any resulting error messages are the ones intended.

## [Criterion](https://lib.rs/crates/criterion)

> Helps you write fast code by detecting and measuring performance improvements or regressions, even small ones, quickly and accurately. You can optimize with confidence, knowing how each change affects the performance of your code.

# Other Libraries

## [Regex](https://lib.rs/crates/regex)

> A Rust library for parsing, compiling, and executing regular expressions. Its syntax is similar to Perl-style regular expressions, but lacks a few features like look around and backreferences. In exchange, all searches execute in linear time with respect to the size of the regular expression and search text.

## [lazy-static](https://lib.rs/crates/lazy_static)

> A macro for declaring lazily evaluated statics in Rust.
> 
> Using this macro, it is possible to have statics that require code to be executed at runtime in order to be initialized. This includes anything requiring heap allocations, like vectors or hash maps, as well as anything that requires non-const function calls to be computed.

## [Rayon](https://lib.rs/crates/rayon)

> Rayon is a data-parallelism library for Rust. It is extremely lightweight and makes it easy to convert a sequential computation into a parallel one. It also guarantees data-race freedom.

## [serde](https://lib.rs/crates/serde)

> Serde is a framework for serializing and deserializing Rust data structures efficiently and generically.

> The Serde ecosystem consists of data structures that know how to serialize and deserialize themselves along with data formats that know how to serialize and deserialize other things. Serde provides the layer by which these two groups interact with each other, allowing any supported data structure to be serialized and deserialized using any supported data format.

### [typetag](https://lib.rs/crates/typetag)

> Serde serializable and deserializable trait objects.
> 
> This crate provides a macro for painless serialization of `&dyn Trait` trait objects and serialization + deserialization of `Box<dyn Trait>` trait objects.

## [Crossbeam](https://lib.rs/crates/crossbeam)

> A set of tools for concurrent programming.

## [Itertools](https://lib.rs/crates/itertools)

> Extra iterator adapters, functions and macros.

## [Rand](https://lib.rs/crates/rand)

> A Rust library for random number generation.
> 
> Rand provides utilities to generate random numbers, to convert them to useful types and distributions, and some randomness-related algorithms.

## [log](https://lib.rs/crates/log)

> A Rust library providing a lightweight logging facade.

## [WalkDir](https://lib.rs/crates/walkdir)

> A cross platform Rust library for efficiently walking a directory recursively. Comes with support for following symbolic links, controlling the number of open file descriptors and efficient mechanisms for pruning the entries in the directory tree.

## [Directories](https://lib.rs/crates/directories)

> A tiny mid-level library that provides platform-specific standard locations of directories for config, cache and other data on Linux, Windows and macOS by leveraging the mechanisms defined by the XDG base/user directory specifications on Linux, the Known Folder API on Windows, and the Standard Directory guidelines on macOS.

## [tempfile](https://lib.rs/crates/tempfile)

> A secure, cross-platform, temporary file library for Rust. In addition to creating temporary files, this library also allows users to securely open multiple independent references to the same temporary file (useful for consumer/producer patterns and surprisingly difficult to implement securely).

## [num](https://lib.rs/crates/num)

> A collection of numeric types and traits for Rust, including bigint, complex, rational, range iterators, generic integers, and more!

## [StructOpt](https://lib.rs/crates/structopt)

> Parse command line argument by defining a struct. It combines clap with custom derive.

## [ScopeGuard](https://lib.rs/crates/scopeguard)

> Rust crate for a convenient RAII scope guard that will run a given closure when it goes out of scope, even if the code between panics (assuming unwinding panic).

## [ref-cast](https://lib.rs/crates/ref-cast)

> Safely cast `&T` to `&U` where the struct `U` contains a single field of type `T`.

## [select-rustc](https://lib.rs/crates/select-rustc)

> Macros for conditional compilation according to rustc compiler version, analogous to `#[cfg(...)]` and `#[cfg_attr(...)]`.