Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: 修改Rust代码注释风格文档 #471

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions docs/community/code_contribution/rust-coding-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn foo() -> Result<(), SystemError> {

## 3. 注释

&emsp;&emsp;DragonOS的注释风格与Rust官方的不太一样,我们部分结合了Linux的注释风格。同时,我们推荐您在代码中加入尽可能多的有效注释,以便于其他人理解您的代码。并且,变量、函数等声明,遵守第一节中提到的命名规范,使其能够“自注释”。
&emsp;&emsp;DragonOS的注释风格与Rust官方的保持一致。同时,我们推荐您在代码中加入尽可能多的有效注释,以便于其他人理解您的代码。并且,变量、函数等声明,遵守第一节中提到的命名规范,使其能够“自注释”。

### 3.1 函数注释

Expand All @@ -72,21 +72,21 @@ fn foo() -> Result<(), SystemError> {
&emsp;&emsp;函数注释的格式如下:

```rust
/// @brief 函数的功能
/// # 函数的功能
///
/// 函数的详细描述
///
/// @param 参数1 参数1的说明
/// ## 参数
///
/// @param 参数2 参数2的说明
/// - 参数1: 参数1的说明
/// - 参数2: 参数2的说明
/// - ...
///
/// @return 返回值的说明
```

&emsp;&emsp;如果函数的返回值是`Result`类型,那么返回值应当这样进行解释:

```rust
/// @return Ok(返回值类型) 返回值的说明
/// ## 返回值
/// - Ok(返回值类型): 返回值的说明
/// - Err(错误值类型): 错误的说明
///
/// ## Safety
///
/// @return Err(错误值类型) 错误的说明
/// 函数的安全性说明
```