Book Image

Rust Standard Library Cookbook

By : Jan Hohenheim, Daniel Durante
Book Image

Rust Standard Library Cookbook

By: Jan Hohenheim, Daniel Durante

Overview of this book

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.
Table of Contents (12 chapters)

How it works...

As a HashSet is a kind of HashMap, most of its interface is pretty similar. The major difference is that the methods that would return a key's value in the HashMap instead simply return a bool on the HashSet in order to tell if a key already existed or not [14].

Additionally, HashSet brings a few methods for analyzing two sets [46 to 92] and joining them [96 to 131]. If you've ever heard of set theory or Venn diagrams, or done a bit of SQL, you're going to recognize it all. Otherwise, I advise you to run the example, and study the outputs in combination with the relevant comments.

Some illustrations might help you. For the analytical methods, the dark green part is the object of reference:

For the selecting methods, the dark green part is the one that is returned: