知识卡片
所需参数明确提示
宏诊断可以同时说明哪里有误以及怎样补齐输入。书中 Shuttle 用返回类型检查提示应返回服务,并附文档入口。Leptos 的历史 view! 示例在能定位错误时用现有标点 token 的跨度,缺少预期上下文时在调用点给出完整用法。这种选择适用于输入不完整、没有可直接标记的目标节点的情况。
相关卡片 [[用跨度指向宏输入错误]]、[[宏诊断的中止与继续]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- From panic to result: Error handling 诊断在真实宏中的用法 · 查看原书依据
Shuttle, an “infrastructure from code” project that we mentioned in chapter 1, relies on proc_macro_error. Here they are checking the return type—just like us! Besides a hint, Shuttle also adds a reference to documentation with doc:
参考来源
- 位置:《Write Powerful Rust Macros》第07章《From panic to result: Error handling》(book-source:extracted/Write Powerful Rust Macros/_epub-src/OEBPS/Text/chapter-7.xhtml#p189)
- 结论依据:7.10 对照 Shuttle 的返回类型帮助信息和 Leptos 的具体标点跨度或调用点诊断。
- 原始内容:Shuttle, an “infrastructure from code” project that we mentioned in chapter 1, relies on proc_macro_error. Here they are checking the return type—just like us! Besides a hint, Shuttle also adds a reference to documentation with doc: