Rust编程:文档生成、测试与算术表达式求值项目实践
1. Rust文档生成与测试
在Rust中, rustdoc 可从crate的文档注释中提取文档。以下是具体操作步骤:
- 添加文档注释 :在 integ-test-example 项目的 src/lib.rs 中添加如下注释:
//! This is a library that contains functions
related to
//! dealing with processes,
//! and makes these tasks more convenient.
use std::process;
/// This function gets the process ID of the
current
/// executable. It returns a non-zero number
pub fn get_process_id() -> u32 {
process::id()
}
- 生成HTML文档 :运行
cargo doc –open命令,即可查看与文档注释对应的生成的HTML文档。
使用Markdown文件编写文档
- 创建文件 :在crate根目录下创建一个新文件夹
超级会员免费看
订阅专栏 解锁全文
42

被折叠的 条评论
为什么被折叠?



