← 返回卡片

原书出处

Write Powerful Rust Macros

06 Testing a builder macro 白盒验证输出

核验版本的摘录快照 · 导入于 2026-11-25T09:20:41.654Z

This is very basic, but it already gives us some assurance about our code. For example, we now know that the code is returning the builder name somewhere in its output. But would it not be better to check that the entire output matches our expectations? We can do that by comparing the output with a TokenStream of our own. That does mean we need to somehow manually build that expected output, and there are several ways to do this.

For example, we could create a new

此预览只包含定位所需的摘录和上下文。

原书定位详情

来源:a19c7933-4eda-4176-aebd-30fe7e1ad292

正文位置:extracted/Write Powerful Rust Macros/_epub-src/OEBPS/Text/chapter-6.xhtml#p42

EPUB SHA-256:68c7ed23324b44144895c3bb55f55731454da237867b66ec66ca6404f5b93661