Macros are a powerful tool for generating code that would be difficult or tedious to write by hand. Rust is a programming language that supports a macro system called procedural macros. The programmer can define a procedural macro by using standard Rust code on a stream of tokens and thus does not have to rely on a domain-specific language for writing macros.
Usually, when someone wants to write procedural macros, they would use the libraries syn
and quote
. syn
is a library for parsing token streams to data structures, and quote
reads data structures and produce token streams. Both libraries are useful because of the flexibility they offer. However, they don’t solve some of the hard problems with macros in Rust that arise from dealing with lifetimes and generics.
This thesis introduces a new library called reflect
, designed to deal with some of the hard problems with procedural macros.
supervisors | Martin Steffen |
IFI links | abstract, thesis, presentation |
github | reflect library |