My opinion is that variance, as traditionally formulated, assumes a "GC'd language", and isn't a good fit for Rust. Let's talk about variance more closely, how it works but also why it's not a great fit for Rust.
Rationale
Relevant to various bits of design work we could undertake, e.g. variance for associated types and trait matching.
Notes
Some notes to myself:
Cell<T> is invariant, but if you own the Cell, it could be covariant
&mut (dyn Foo + 'a) is invariant with respect to 'a but doesn't really need to be
Summary
My opinion is that variance, as traditionally formulated, assumes a "GC'd language", and isn't a good fit for Rust. Let's talk about variance more closely, how it works but also why it's not a great fit for Rust.
Rationale
Relevant to various bits of design work we could undertake, e.g. variance for associated types and trait matching.
Notes
Some notes to myself:
Cell<T>
is invariant, but if you own theCell
, it could be covariant&mut (dyn Foo + 'a)
is invariant with respect to'a
but doesn't really need to be