rust - What is the meaning of 'static as a function constraint? - Stack Overflow
fn foo<F: T + 'static>(f: F) {}
在類型約束中的生命周期泛型表示該類型的所有生命周期泛型參數都必須滿足生命周期約束. 比如, 如下結構體
struct Kate<'a, 'b> {
address: &'a str,
lastname: &'b str,
}
Kate<'a, 'b>
只有在 'a = 'static
和 'b='static
時滿足 F: 'static
.
對於沒有生命周期泛型的結構體來說, 它們滿足任何的生命周期約束.
F: 'static
意味着:
F
沒有生命周期泛型參數- 所有的生命周期參數都是
'static