> There is a special lifetime, named 'static, which is valid for the entire program's lifetime. I've heard this many times before, but as the guide[1] says: "You might encounter it in two situations... Both are related but subtly different and this is a common source for confusion when learning Rust." 'static means different things for references and trait objects. ie. 'a: 'static --> reference with lifetime 'a lives…
The wording that "'static means different things" is a bit misleading. It means the same thing, but the meaning different because of the context: Lifetime: lifetime means that the first lifetime outlives (is as long or longer) the second Type: lifetime means that the type is constrained by the lifetime. Because 'static means "the lifetime of the whole process". That means that the type is not constrained.
T: ‘a is T outlives ‘a; but types are not generated at runtime.
All types are static; which is to say they are created at compile time and exist for the lifetime of the program.
Or does rust generate type variants on the fly at runtime?
I didn’t think it did...
It is a constraint applied to arguments at compile time... but r, that’s what I thought anyway.