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...
About "Cookin' with Rust" Table of contents • Who this book is for • How to read this book • How to use the recipes • A note about error handling • A note about crate representation Who this book is for This cookbook is intended for new Rus...
Algorithms | Recipe | Crates | Categories | |--------|--------|------------| | Generate random numbers | [![rand-badge]][rand] | [![cat-science-badge]][cat-science] | | Generate random numbers within a range | [![rand-badge]][rand] | [![cat...
Asynchronous | Recipe | Crates | Categories| |-------|-------|----------| | Tokio Runtime |[![tokio-badge]][tokio]| [![cat-asynchronous-badge]][cat-asynchronous] | | Tokio Runtime Builder |[![tokio-badge]][tokio] [![std-badge]][std]| [![cat...
Async Runtime When your program asks for something that takes time, e.g reading a file, fetching data from a server, waiting for a timer, it has two choices: sit and wait doing nothing, or go do something else while it waits. Blocking means...
Timeouts [![tokio-badge]][tokio] [![std-badge]][std] Sometimes a task takes too long and you don't want to wait forever. A timeout puts a time limit on a task. If it finishes in time you get the result, if it doesn't, it is cancelled and yo...
Message Passing When your program has multiple tasks running at the same time, they sometimes need to talk to each other. Channels are how you do that, one task sends a message, another receives it. Think of it like a pipe: you put somethin...
Structured Concurrency When your program runs multiple tasks at the same time, you need a way to keep track of them, know when they finish, collect their results, and clean up if something goes wrong. This section shows how to do that. Join...
Command Line | Recipe | Crates | Categories | |--------|--------|------------| | Parse command line arguments | [![std-badge]][std] | [![cat-command-line-badge]][cat-command-line] | | Clap Basic Argument Parsing | [![clap-badge]][clap] | [!...
Parse command line arguments
Environment Variables The env module lets you inspect and manipulate the process environment, including env vars, CLI args, and working directories. Get Environment Variables var fetches an env var from the current process. It returns Resul...
Compression | Recipe | Crates | Categories | |--------|--------|------------| | Decompress a tarball | [![flate2-badge]][flate2] [![tar-badge]][tar] | [![cat-compression-badge]][cat-compression] | | Compress a directory into a tarball | [![...
Concurrency | Recipe | Crates | Categories | |--------|--------|------------| | Spawn a short-lived thread | [![crossbeam-badge]][crossbeam] | [![cat-concurrency-badge]][cat-concurrency] | | Create a parallel data pipeline | [![crossbeam-ba...