0%

Book Description

Explore the Rust Standard library and compose algorithms with minimal dependency on external libraries

About This Book

  • 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.

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.

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.

In Detail

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.

Style and approach

This recipe-based practical guide presents each topic with step-by-step instructions on how you can create fast and efficient applications utilizing Rust's Standard library packages.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Rust Standard Library Cookbook
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the authors
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    5. Get in touch
      1. Reviews
    6. Disclaimer
  6. Learning the Basics
    1. Introduction
    2. Concatenating strings
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Using the format! macro
      1. How to do it...
      2. How it works...
      3. There's more...
    4. Providing a default implementation
      1. How to do it...
      2. How it works...
    5. Using the constructor pattern
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Using the builder pattern
      1. How to do it...
      2. How it works...
      3. There's more...
    7. Parallelism through simple threads
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    8. Generating random numbers
      1. How to do it...
      2. How it works...
      3. There's more...
    9. Querying with regexes
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    10. Accessing the command line
      1. How to do it...
      2. How it works...
      3. There's more...
    11. Interacting with environment variables
      1. How to do it...
      2. How it works...
      3. There's more...
    12. Reading from stdin
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    13. Accepting a variable number of arguments
      1. Getting started
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  7. Working with Collections
    1. Introduction
    2. Using a vector
      1. How to do it...
      2. How it works...
      3. There's more...
    3. Using a string
      1. How to do it...
      2. How it works...
      3. There's more...
    4. Accessing collections as iterators
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    5. Using a VecDeque
      1. How to do it...
      2. How it works...
      3. There's more...
    6. Using a HashMap
      1. How to do it...
      2. How it works...
      3. There's more...
    7. Using a HashSet
      1. How to do it...
      2. How it works...
      3. There's more...
    8. Creating an own iterator
      1. How to do it...
      2. How it works...
      3. There's more...
    9. Using a slab
      1. How to do it...
      2. How it works...
      3. There's more...
  8. Handling Files and the Filesystem
    1. Introduction
    2. Working with text files
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    3. Handling bytes
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Working with binary files
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    5. Compressing and decompressing data
      1. How to do it...
      2. How it works...
      3. There's more...
    6. Traversing the filesystem
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Finding files with glob patterns
      1. How to do it...
      2. How it works...
      3. See also
  9. Serialization
    1. Introduction
    2. Working with CSV
      1. Getting started
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Serialization basics with Serde
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    4. Working with TOML
      1. Getting started
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Working with JSON
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Building JSON dynamically
      1. How to do it...
      2. How it works...
      3. See also
  10. Advanced Data Structures
    1. Introduction
    2. Creating lazy static objects
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    3. Working with bit fields
      1. Getting started
      2. How to do it...
      3. How it works...
      4. See also
    4. Providing custom derives
      1. Getting started
      2. How to do it...
      3. How it works...
      4. There's more...
    5. Converting types into each other
      1. How to do it...
      2. How it works...
    6. Boxing data
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    7. Sharing ownership with smart pointers
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    8. Working with interior mutability
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
  11. Handling Errors
    1. Introduction
    2. Providing user-defined error types
      1. How to do it...
      2. How it works...
      3. There's more...
    3. Providing logging
      1. How to do it...
      2. How it works...
      3. There's more...
    4. Creating a custom logger
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    5. Implementing the Drop trait
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    6. Understanding RAII
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
  12. Parallelism and Rayon
    1. Introduction
    2. Parallelizing iterators
      1. How to do it...
      2. How it works...
      3. See also
    3. Running two operations together
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    4. Sharing resources in multithreaded closures
      1. How to do it...
      2. How it works...
      3. See also
    5. Sending data across threads
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    6. Accessing resources in parallel with RwLocks
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    7. Atomically accessing primitives
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    8. Putting it all together in a connection handler
      1. How to do it...
      2. How it works...
      3. There's more...
  13. Working with Futures
    1. Introduction
    2. Providing futures with a CPU pool and waiting for them
      1. How to do it...
      2. How it works...
    3. Handling errors in futures
      1. How to do it...
      2. How it works...
      3. See also
    4. Combining futures
      1. How to do it...
      2. How it works...
      3. See also
    5. Using Streams
      1. How to do it...
      2. How it works...
    6. Using Sinks
      1. How to do it...
      2. How it works...
    7. Using the oneshot channel
      1. How to do it...
      2. How it works...
    8. Returning futures
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    9. Locking resources with BiLocks
      1. How to do it...
      2. How it works...
  14. Networking
    1. Introduction
    2. Setting up a basic HTTP server
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Configuring an HTTP server to perform echoing and routing
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Configuring an HTTP server to perform file serving
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    5. Making requests to APIs
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
  15. Using Experimental Nightly Features
    1. Introduction
    2. Iterating over an inclusive range
      1. How to do it...
      2. How it works...
      3. See also
    3. Returning abstract types
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    4. Composing functions
      1. How to do it...
      2. How it works...
      3. See also
    5. Filtering strings efficiently
      1. How to do it...
      2. How it works...
      3. See also
    6. Stepping through an iterator in regular intervals
      1. How to do it...
      2. How it works...
      3. See also
    7. Benchmarking your code
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    8. Using generators
      1. How to do it...
      2. How it works...
      3. See also
  16. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
3.141.25.41