3 ms·
https://doc.rust-lang.org/reference/subtyping.html#variance https://doc.rust-lang.org/reference/subtyping.html#variance Lifetimes imply the need for the idea o
by tialaramex 1y ago
https://doc.rust-lang.org/reference/subtyping.html#variance https://doc.rust-lang.org/reference/subtyping.html#variance
Lifetimes imply the need for the idea of variance.
- kibwen 1y agoRather, any language with both generics and subtyping needs to consider variance, and Rust doesn't have subtyping in general, but lifetimes do technically have subtyping relationships, so lifetimes are the only place where this matters, and fortunately Rust can just infer the right behavior based on some simple type-level heuristics.
- James_K 1y agoUnfortunately, more like. I'd much rather have some explicit syntax for it that potentially never realise it's a feature. I was baffled beyond belief the first time the compiler asked me to put a ghost in my struct.