知识卡片

普通读书笔记卡 · 6074.d.1.a.3.c.4.a

函数式过程宏自行解释输入

理解等级:中级

函数式过程宏收到单个TokenStream,即使调用看起来有多个参数,也需自行解析其结构。不能简单按逗号切开任意嵌套语法。声明宏匹配模式足够时更容易表达输入约束;需要更自由语法时再用过程宏,并提供明确诊断。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 5. Tooling Function-like macros · 查看原书依据

      Function-like macros Function-like procedural macros are invoked with an argument, and the macro definition has access to the parsed tokens that make up the argument, and emits arbitrary tokens as a result. Note that the previous sentence says “argument,” singular—even if a function-like macro is invoked with what looks like multiple arguments: my_func_macro

    参考来源

    - 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第5章《Function-like macros》(spine9;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch05.html;u144-ch05-012)。 - 结论依据:原文在“Function-like macros”附近的定义、例子或代码支撑本卡核心说明:函数式过程宏收到单个TokenStream,即使调用看起来有多个参数,也需自行解析其结构。边界按已读前提解释;示例未执行。 - 原始内容:Function-like macros Function-like procedural macros are invoked with an argument, and the macro definition has access to the parsed tokens that make up the argument, and emits arbitrary tokens as a result. Note that the previous sentence says “argument,” singular—even if a function-like macro is invoked with what looks like multiple arguments: my_func_macro