Earlier quoted context omitted.
You misunderstand; what confuses me is how 'static can mean the same thing in both of these contexts. T: 'static does not mean the references in T must exist for the lifetime of the application. Ie. the lifetime constraint on T isn’t the same 'static from &'static where the reference must life for the entire lifetime of the application. Types are static. T: 'static applies to instances at runtime. These instances do…
Sorry, I probably edited my comment while you were replying and added a couple links. Check misconception 2 here, I think it addresses your point. https://github.com/pretzelhammer/rust-blog/blob/master/posts... EDIT to your edit: > 'static in this context would mean that all instances of T must be 'static. You mean in T: 'static? No. It means that any instance passed as type T must be bound by 'static and therefore c…
I just maintain that the word 'static is being overloaded here to mean multiple different things.
'static is not the "lifetime of the entire application" when it is used in the context of T: 'static.
> It can have references in it! As long as they're bound by 'static.
:)
...but it can also have values in it which are not 'static.
So is T: 'static, or not?
It's arbitrary semantics; ...but my take on it is:
- IF you take "x is 'static" as meaning the "X is valid for entire lifetime of the application"
then if:
- x: &'static 'is static' and must be valid for the entire lifetime of the application.
I would expect:
- x: T + 'static 'is static' and must be valid for the entire lifetime of the application.
I'm happy to agree that's not what it does mean, what I'm saying is that it is inconsistent for it not to mean that.