'What does it mean `T : 'static`? [duplicate]
What is the proper understanding of the restriction T : 'static ?
As I understand it means "anything implementing T should not have a reference / pointer either directly or indirectly". I am asking because I used to think that it means anything implementing T should exist during the whole lifetime of the application, but such interpretation looks wrong for me now.
Solution 1:[1]
Your new understanding is correct. T: 'static means T does not contain lifetimes, or may live during the entire program, but doesn't have to.
See also Common Lifetime Misconceptions: if T: 'static then T must be valid for the entire program.
For example, String: 'static holds, but you can drop a String whenever you want and you cannot access it anymore. It is just that if I have a String and I don't drop it, I can hold it forever without have to worry it will be invalidated behind my back because, say, the underlying storage was freed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
