← 返回卡片

原书出处

Write Powerful Rust Macros

04 Making fields public with attribute macros 重建时遇到的信息损失

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

A much bigger problem is that when we have other macros annotating our struct, they are deleted by ours. Try adding a #[derive(Debug)] below our annotation and running cargo expand. Do you see how the additional annotation vanishes into thin air? We are simply superb at making things disappear. As macros are executed in order, from top to bottom, the simple workaround is adding the derive above our #[public]. Now everything will work as

expected. Except—please do not do this. Instead,

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

原书定位详情

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

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

EPUB SHA-256:68c7ed23324b44144895c3bb55f55731454da237867b66ec66ca6404f5b93661