Advanced Data Structures

In this chapter, we will cover the following recipes:

  • Creating lazy static objects
  • Working with bit fields
  • Providing custom derives
  • Converting types into each other
  • Boxing data
  • Sharing ownership with smart pointers
  • Working with interior mutability

Introduction

So far, we have primarily looked at techniques that were all useful in their own right. Of course, we are continuing that trend, but the recipes shown in this chapter truly shine when combined with other code. You can imagine them as the glue holding a nice Rust program together, as they are primarily oriented toward new enabling ways in which different components of your crate can work together.

Creating lazy static objects

Big objects, especially constant ...

Get Rust Standard Library Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.