7 Using traits, generics, and structs for specialized tasks

This chapter covers

  • Using const generics
  • Applying traits to external crate types
  • Extending types with extension traits
  • Implementing blanket traits
  • Using marker traits to mark types with attributes
  • Tagging with structs
  • Providing access to internal data with reference objects

The previous chapters introduced several Rust advanced techniques. This chapter expands on some of those themes and explores more advanced design patterns. These patterns are useful in many circumstances, but you’ll likely use them less frequently because they are more complex to implement and often apply to scenarios that you may not encounter often.

To use an analogy, the patterns discussed in the previous ...

Get Idiomatic Rust 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.