Skip to content

Commit 9787c24

Browse files
author
WaySLOG
committed
Merge pull request #352 from wayslog/master
bug fixed: change into two table code block
2 parents 6c0f2d5 + 228f3bf commit 9787c24

1 file changed

Lines changed: 27 additions & 22 deletions

File tree

quickstart/comments-document.md

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,40 @@
44
在 Rust 里面注释分成两种,行注释和块注释。它的形式和 C 语言是一样的。
55
两种注释分别是:
66
> 1. 行注释使用 `//` 放在注释前面。比如:
7-
`// I love Rust, but I hate Rustc.`
8-
2. 块注释分别使用`/*``*/`包裹需要注释的内容。比如:
9-
`/* W-Cat 是个大胖猫,N-Cat 是个高度近视猫。*/`
7+
```
8+
// I love Rust, but I hate Rustc.
9+
```
10+
11+
> 2. 块注释分别使用`/*``*/`包裹需要注释的内容。比如:
12+
```
13+
/* W-Cat 是个大胖猫,N-Cat 是个高度近视猫。*/
14+
```
1015

1116
## 文档
1217
Rust 自带有文档功能的注释,分别是`///``//!`。支持 Markdown 格式
1318
1. `///`用来描述的它后面接着的项。
1419
2. `//!`用来描述包含它的项,一般用在模块文件的头部。
1520
比如在 main.rs 文件中输入以下内容:
16-
```rust
17-
//! # The first line
18-
//! The second line
1921

20-
/// Adds one to the number given.
21-
///
22-
/// # Examples
23-
///
24-
/// ```
25-
/// let five = 5;
26-
///
27-
/// assert_eq!(6, add_one(5));
28-
/// # fn add_one(x: i32) -> i32 {
29-
/// # x + 1
30-
/// # }
31-
/// ```
32-
fn add_one(x: i32) -> i32 {
33-
x + 1
34-
}
35-
```
22+
//! # The first line
23+
//! The second line
24+
/// Adds one to the number given.
25+
///
26+
/// # Examples
27+
///
28+
/// ```
29+
/// let five = 5;
30+
///
31+
/// assert_eq!(6, add_one(5));
32+
/// # fn add_one(x: i32) -> i32 {
33+
/// # x + 1
34+
/// # }
35+
/// ```
36+
fn add_one(x: i32) -> i32 {
37+
x + 1
38+
}
39+
40+
3641
### 生成 html 文档
3742
* `rustdoc main.rs`
3843

0 commit comments

Comments
 (0)