← 返回卡片

原书出处

Write Powerful Rust Macros

apxA Exercise solutions 第 7 章练习:局部修改与遍历边界

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

There are several solutions.

What complicates matters a bit is that Data—among others—does not implement Parse. FieldsNamed does, however, so we put our public fields in curly braces. That way, we can parse them into FieldsNamed. And we wrap the output in the correct Data struct, replacing the existing data field of our AST (which has become mutable to make this possible). We also set the visibility to public. In both cases, we make good use of the Default trait.

When that’s done, we can change it

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

原书定位详情

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

正文位置:extracted/Write Powerful Rust Macros/_epub-src/OEBPS/Text/appendix-a.xhtml#p104

EPUB SHA-256:68c7ed23324b44144895c3bb55f55731454da237867b66ec66ca6404f5b93661