modify confusing variance example by lcnr · Pull Request #1224 · rust-lang/reference (original) (raw)
Seems right. To be 100% pedantic, you would talk about the "variance of a (struct/enum/union) type Foo<T, U>
with respect to its type parameters T
(or U
)". i.e., if Foo
is covariant with respect to T
, then if you have Foo<A>
and Foo<B>
for some types A
and B
, Foo<A> <: Foo<B>
iff A <: B
.
Given that fn
is not a struct/enum/union type that is parameterized by T
, it's not really correct to say that fn(T)
is contravariant with respect to T
. You say that fn
is contravariant with respect to its arguments (and covariant with respect to its return type).