-
Book Overview & Buying
-
Table Of Contents
Rust for C++ Developers
By :
Metaprogramming is the practice of writing code that generates or manipulates other code. In many programming languages, metaprogramming capabilities rely on a type of macro expansion system. Macros are a powerful tool in many programming languages, including C++, where they function as a system to generate code through expansion and replacement of text.
The Rust macro system is fundamentally different from C++, and it gives programmers a great deal of additional power. In fact, the Rust macro system encompasses several different types of macros, divided into the categories of declarative macros and procedural macros. This chapter examines the differences between C++ and Rust's macro systems and shows several examples of how to use the Rust macro system to improve our programs.
In this chapter, we're going to cover the following main topics: