3. Macros

Macros

A number of minor features of Rust are not central enough to have their own syntax, and yet are not implementable as functions. Instead, they are given names, and invoked through a consistent syntax: some_extension!(...).

Users of rustc can define new macros in two ways:

  • Macros define new syntax in a higher-level, declarative way.
  • Procedural Macros can be used to implement custom derive.

And one unstable way: compiler plugins.

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/reference/macros.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部