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

Update advance.md #1346

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/advance/lifetime/advance.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ impl Reader for BufReader<'_> {
}
```

`'_` 生命周期表示 `BufReader` 有一个不使用的生命周期,我们可以忽略它,无需为它创建一个名称。
`'_` 称为匿名生命周期(anonymous lifetime),在这里表示 `BufReader` 有一个不使用的生命周期,我们可以忽略它,无需为它创建一个名称。

歪个楼,有读者估计会发问:既然用不到 `'a`,为何还要写出来?如果你仔细回忆下上一节的内容,里面有一句专门用粗体标注的文字:**生命周期参数也是类型的一部分**,因此 `BufReader<'a>` 是一个完整的类型,在实现它的时候,你不能把 `'a` 给丢了!

Expand Down