O'Reilly logo

Mastering Rust by Vesa Kaihlavirta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Macros 1.1 - custom derives

The Rust team is working on stabilizing a significant subset of the compiler plugins mechanism, which should be large enough to be used for a majority of the things libraries usually use compiler plugins for, but small enough to be stabilized. This standardization attempt is called macros 1.1, and both the design and implementation have been stabilized and are available in the stable compiler since early 2017.

Macros 1.1 will give us the ability to write custom derives for structs and enums. This may not seem like much, but it is, in fact, exactly what the aforementioned major libraries needed. The implementation details consist of three things:

  • A new crate type, proc-macro, which declares a crate as a macro crate ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required