24 ms·
`static is actually the superlifetime of all lifetimes, but & is contravariant in its lifetime parameter (and covariant in its type parameter).
by cwzwarich 3y ago
`static is actually the superlifetime of all lifetimes, but & is contravariant in its lifetime parameter (and covariant in its type parameter).
- almost_usual 3y agoMind expanding on this? The nomicon describes &’a T where both ‘a’ and ‘T’ are covariant. I thought I had a clear picture but now I’m confused. https://doc.rust-lang.org/nomicon/subtyping.html#variance https://doc.rust-lang.org/nomicon/subtyping.html#variance
- cwzwarich 3y agoHere is the original GitHub issue on the question: https://github.com/rust-lang/rust/issues/15699 https://github.com/rust-lang/rust/issues/15699 And an RFC by some people that felt frustrated by this arguably implementation-centric view that kind of lost steam: https://github.com/rust-lang/rfcs/issues/391 https://github.com/rust-lang/rfcs/issues/391 Intuitively, the bottom lifetime should the one that is uninhabited, which would be a lifetime with no extent rather than 'static.
- almost_usual 3y agoInteresting, thanks for sharing!
- Georgelemental 3y ago`rustc` used to use different terminology than the nomicom, but this is no longer the case: https://github.com/rust-lang/rust/pull/107339 https://github.com/rust-lang/rust/pull/107339
- Georgelemental 3y agoThis is not true anymore: https://github.com/rust-lang/rust/pull/107339 https://github.com/rust-lang/rust/pull/107339