mirror of
https://github.com/gnu4cn/rust-lang-zh_CN.git
synced 2026-08-19 12:43:28 +08:00
Updated src/generic_types_traits_and_lifetimes/lifetimes.md'.
This commit is contained in:
@@ -496,10 +496,7 @@ let s: &'static str = "我有静态的生命周期。";
|
||||
在一些错误消息中,咱们或许会看到使用 `'static` 生命周期的建议。不过在给引用指定 `'static` 生命周期之前,请考虑一下手头的这个引用,是否会存活到整个程序的生命周期,以及咱们是否想要他存活到整个程序的生命周期。多数时候,建议 `'static` 生命周期的错误消息,都是由尝试创建悬空引用,或可用生命周期不匹配导致。在这些情况下,解决办法是修复这些问题,而非指定出 `'static` 生命周期。
|
||||
|
||||
|
||||
## 泛型参数、特质边界与生命周期三位一体
|
||||
|
||||
**Generic Type Parameters, Trait Bounds, and Lifetimes Together**
|
||||
|
||||
# 泛型类型参数、特质边界与生命周期
|
||||
|
||||
咱们来简要地看看,在一个函数中,一起指定出泛型参数、特质边界与生命周期的语法!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user