mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2024-11-13 03:21:20 +08:00
Update ch19-02-advanced-lifetimes.md
This commit is contained in:
parent
619d09edea
commit
74d7251346
@ -1,13 +1,13 @@
|
|||||||
## Advanced Lifetimes
|
## 高级生命周期
|
||||||
|
|
||||||
Back in Chapter 10, we learned how to annotate references with lifetime
|
回到第10章, we learned how to annotate references with lifetime
|
||||||
parameters to help Rust understand how the lifetimes of different references
|
parameters to help Rust understand how the lifetimes of different references
|
||||||
relate. We saw how most of the time, Rust will let you elide lifetimes, but
|
relate. We saw how most of the time, Rust will let you elide lifetimes, but
|
||||||
every reference has a lifetime. There are three advanced features of lifetimes
|
every reference has a lifetime. There are three advanced features of lifetimes
|
||||||
that we haven't covered though: *lifetime subtyping*, *lifetime
|
that we haven't covered though: *lifetime subtyping*, *lifetime
|
||||||
bounds*, and *trait object lifetimes*.
|
bounds*, and *trait object lifetimes*.
|
||||||
|
|
||||||
### Lifetime Subtyping
|
### 生命周期子类型
|
||||||
|
|
||||||
Imagine that we want to write a parser. To do this, we'll have a structure that
|
Imagine that we want to write a parser. To do this, we'll have a structure that
|
||||||
holds a reference to the string that we're parsing, and we'll call that struct
|
holds a reference to the string that we're parsing, and we'll call that struct
|
||||||
|
Loading…
Reference in New Issue
Block a user