Cookin' with Rust

This Rust Cookbook is a collection of simple examples that demonstrate good practices to accomplish common programming tasks, using the crates of the Rust ecosystem.

Read more about Rust Cookbook, including tips for how to read the book, how to use the examples, and notes on conventions.

Contributing

This project is intented to be easy for new Rust programmers to contribute to, and an easy to way get involved with the Rust community. It needs and welcomes help. For details see CONTRIBUTING.md.

Basics

Recipe Crates Categories
Read lines of strings from a file std-badge cat-filesystem-badge
Read and write integers in little-endian byte order byteorder-badge cat-encoding-badge
Generate random floating point numbers rand-badge cat-science-badge
Generate random values on a custom type rand-badge cat-science-badge

Encoding

Recipe Crates Categories
Serialize and deserialize unstructured JSON serde-json-badge cat-encoding-badge
Deserialize a TOML configuration file toml-badge cat-encoding-badge

Concurrency

Recipe Crates Categories
Mutate the elements of an array in parallel rayon-badge cat-concurrency-badge

Networking

Recipe Crates Categories
Parse a URL from a string to a Url type url-badge cat-net-badge
Create a base URL by removing path segments url-badge cat-net-badge
Create new URLs from a base URL url-badge cat-net-badge
Extract the URL origin (scheme / host / port) url-badge cat-net-badge
Remove fragment identifiers and query pairs from a URL url-badge cat-net-badge
Serialize a Url url-badge serde-badge cat-net-badge cat-encoding-badge
Make a HTTP GET request after parsing a URL reqwest-badge url-badge cat-net-badge

Application development

Recipe Crates Categories
Parse command line arguments clap-badge cat-command-line-badge
Log a debug message to the console log-badge env_logger-badge cat-command-line-badge
Log an error message to the console log-badge env_logger-badge cat-command-line-badge
Enable log levels per module log-badge env_logger-badge cat-command-line-badge
Log messages to a custom location log-badge cat-command-line-badge