8 Builder with attributes
This chapter covers
- Working with field-level custom attributes to rename methods
- Using root-level custom attributes to decide on error handling
- Making a builder easier to use with type state
- Exploring how derive and attribute macros differ
- Parsing (document) attributes inside function-like macros
Every macro we created thus far had its behavior set in stone. Nothing was customizable. But sometimes you want overridable behavior, because that greatly increases flexibility, or you may need it to meet some requirements. In this chapter, we focus on customization via attributes, which are available for both derive and attribute macros. We will see how we can add information to a macro attribute and other parts of ...
Get Write Powerful Rust Macros 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.