Book description
Explore the Rust Standard library and compose algorithms with minimal dependency on external libraries
Key Features
- Develop high-quality, fast, and portable applications by leveraging the power of Rust's Standard library.
- Practical recipes that will help you work with the Standard library to boost your productivity as a Rust developer.
- Learn about most relevant external crates to be used along with the Standard library.
Book Description
Mozilla's Rust is gaining much attention with amazing features and a powerful library. This book will take you through varied recipes to teach you how to leverage the Standard library to implement efficient solutions.
The book begins with a brief look at the basic modules of the Standard library and collections. From here, the recipes will cover packages that support file/directory handling and interaction through parsing. You will learn about packages related to advanced data structures, error handling, and networking. You will also learn to work with futures and experimental nightly features. The book also covers the most relevant external crates in Rust.
By the end of the book, you will be proficient at using the Rust Standard library.
What you will learn
- How to use the basic modules of the library: strings, command line access, and more.
- Implement collections and folding of collections using vectors, Deque, linked lists, and more.
- Handle various file types, compressing, and decompressing data.
- Search for files with glob patterns.
- Implement parsing through various formats such as CSV, TOML, and JSON.
- Utilize drop trait, the Rust version of destructor.
- Resource locking with Bilocks.
Who this book is for
This book is for developers who would like to explore the power of Rust and learn to use the STL for various functionalities. A basic Rust programming knowledge is assumed.
Table of contents
- Title Page
- Copyright and Credits
- Packt Upsell
- Contributors
- Preface
-
Learning the Basics
- Introduction
- Concatenating strings
- Getting ready
- How to do it...
- How it works...
- Using the format! macro
- How to do it...
- How it works...
- There's more...
- Providing a default implementation
- How to do it...
- How it works...
- Using the constructor pattern
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using the builder pattern
- How to do it...
- How it works...
- There's more...
- Parallelism through simple threads
- How to do it...
- How it works...
- There's more...
- See also
- Generating random numbers
- How to do it...
- How it works...
- There's more...
- Querying with regexes
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Accessing the command line
- How to do it...
- How it works...
- There's more...
- Interacting with environment variables
- How to do it...
- How it works...
- There's more...
- Reading from stdin
- How to do it...
- How it works...
- There's more...
- See also
- Accepting a variable number of arguments
- Getting started
- How to do it...
- How it works...
- There's more...
- See also
-
Working with Collections
- Introduction
- Using a vector
- How to do it...
- How it works...
- There's more...
- Using a string
- How to do it...
- How it works...
- There's more...
- Accessing collections as iterators
- How to do it...
- How it works...
- There's more...
- See also
- Using a VecDeque
- How to do it...
- How it works...
- There's more...
- Using a HashMap
- How to do it...
- How it works...
- There's more...
- Using a HashSet
- How to do it...
- How it works...
- There's more...
- Creating an own iterator
- How to do it...
- How it works...
- There's more...
- Using a slab
- How to do it...
- How it works...
- There's more...
-
Handling Files and the Filesystem
- Introduction
- Working with text files
- How to do it...
- How it works...
- There's more...
- See also
- Handling bytes
- Getting ready
- How to do it...
- How it works...
- There's more...
- Working with binary files
- How to do it...
- How it works...
- There's more...
- See also
- Compressing and decompressing data
- How to do it...
- How it works...
- There's more...
- Traversing the filesystem
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Finding files with glob patterns
- How to do it...
- How it works...
- See also
-
Serialization
- Introduction
- Working with CSV
- Getting started
- How to do it...
- How it works...
- There's more...
- See also
- Serialization basics with Serde
- How to do it...
- How it works...
- There's more...
- See also
- Working with TOML
- Getting started
- How to do it...
- How it works...
- There's more...
- See also
- Working with JSON
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Building JSON dynamically
- How to do it...
- How it works...
- See also
-
Advanced Data Structures
- Introduction
- Creating lazy static objects
- How to do it...
- How it works...
- There's more...
- See also
- Working with bit fields
- Getting started
- How to do it...
- How it works...
- See also
- Providing custom derives
- Getting started
- How to do it...
- How it works...
- There's more...
- Converting types into each other
- How to do it...
- How it works...
- Boxing data
- How to do it...
- How it works...
- There's more...
- See also
- Sharing ownership with smart pointers
- How to do it...
- How it works...
- There's more...
- See also
- Working with interior mutability
- How to do it...
- How it works...
- There's more...
- See also
-
Handling Errors
- Introduction
- Providing user-defined error types
- How to do it...
- How it works...
- There's more...
- Providing logging
- How to do it...
- How it works...
- There's more...
- Creating a custom logger
- How to do it...
- How it works...
- There's more...
- See also
- Implementing the Drop trait
- How to do it...
- How it works...
- There's more...
- See also
- Understanding RAII
- How to do it...
- How it works...
- There's more...
- See also
-
Parallelism and Rayon
- Introduction
- Parallelizing iterators
- How to do it...
- How it works...
- See also
- Running two operations together
- How to do it...
- How it works...
- There's more...
- See also
- Sharing resources in multithreaded closures
- How to do it...
- How it works...
- See also
- Sending data across threads
- How to do it...
- How it works...
- There's more...
- See also
- Accessing resources in parallel with RwLocks
- How to do it...
- How it works...
- There's more...
- See also
- Atomically accessing primitives
- How to do it...
- How it works...
- There's more...
- See also
- Putting it all together in a connection handler
- How to do it...
- How it works...
- There's more...
-
Working with Futures
- Introduction
- Providing futures with a CPU pool and waiting for them
- How to do it...
- How it works...
- Handling errors in futures
- How to do it...
- How it works...
- See also
- Combining futures
- How to do it...
- How it works...
- See also
- Using Streams
- How to do it...
- How it works...
- Using Sinks
- How to do it...
- How it works...
- Using the oneshot channel
- How to do it...
- How it works...
- Returning futures
- How to do it...
- How it works...
- There's more...
- See also
- Locking resources with BiLocks
- How to do it...
- How it works...
-
Networking
- Introduction
- Setting up a basic HTTP server
- Getting ready
- How to do it...
- How it works...
- See also
- Configuring an HTTP server to perform echoing and routing
- Getting ready
- How to do it...
- How it works...
- Configuring an HTTP server to perform file serving
- How to do it...
- How it works...
- There's more...
- See also
- Making requests to APIs
- How to do it...
- How it works...
- There's more...
- See also
-
Using Experimental Nightly Features
- Introduction
- Iterating over an inclusive range
- How to do it...
- How it works...
- See also
- Returning abstract types
- How to do it...
- How it works...
- There's more...
- See also
- Composing functions
- How to do it...
- How it works...
- See also
- Filtering strings efficiently
- How to do it...
- How it works...
- See also
- Stepping through an iterator in regular intervals
- How to do it...
- How it works...
- See also
- Benchmarking your code
- How to do it...
- How it works...
- There's more...
- See also
- Using generators
- How to do it...
- How it works...
- See also
- Other Books You May Enjoy
Product information
- Title: Rust Standard Library Cookbook
- Author(s):
- Release date: March 2018
- Publisher(s): Packt Publishing
- ISBN: 9781788623926
You might also like
book
Rust Programming Cookbook
Practical solutions to overcome challenges in creating console and web applications and working with systems-level and …
book
Practical Machine Learning with Rust: Creating Intelligent Applications in Rust
Explore machine learning in Rust and learn about the intricacies of creating machine learning applications. This …
book
Hands-On Functional Programming in Rust
Explore the support Rust offers for creating functional applications in Rust. Learn about various design patterns, …
book
The Complete Rust Programming Reference Guide
Design and implement professional-level programs by leveraging modern data structures and algorithms in Rust Key Features …