知识卡片
文档注释的两种归属
/// 记录下一项公共定义,//! 用于包含自身的 crate 或模块。Rustdoc 可将 Markdown 注释生成 HTML。运行 cargo doc --open 可检查接口页面及 crate 首页上的总体说明。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 深入 Cargo 与 Crates.io Publishing a Crate to Crates.io · 查看原书依据
The doc comment //! adds documentation to the item that contains the comments rather than to the items following the comments. We typically use these doc comments inside the crate root file (src/lib.rs by convention) or inside a module to document the crate or the module as a whole.
参考来源
- 位置:《The Rust Programming Language(第2版)》第14章 深入 Cargo 与 Crates.io(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c14.xhtml`,块 0049)
- 结论依据:原文用 crate 根或模块里的 `//!` 对比写在项之前的 `///`。
- 原始内容:The doc comment //! adds documentation to the item that contains the comments rather than to the items following the comments. We typically use these doc comments inside the crate root file (src/lib.rs by convention) or inside a module to document the crate or the module as a whole.