From d9abcb680ed5c3556f19344fdf3e858caa4566a4 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 2 Jul 2018 11:12:47 +0200 Subject: [PATCH] Fix definition of contravariance Also clarify what F *is*. --- src/subtyping.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/subtyping.md b/src/subtyping.md index 9cbf2af..b5ce948 100644 --- a/src/subtyping.md +++ b/src/subtyping.md @@ -64,13 +64,13 @@ For instance `Vec` is a type constructor that takes a `T` and returns a `Vec`. `&` and `&mut` are type constructors that take two inputs: a lifetime, and a type to point to. -A type constructor's *variance* is how the subtyping of its inputs affects the +A type constructor F's *variance* is how the subtyping of its inputs affects the subtyping of its outputs. There are three kinds of variance in Rust: * F is *covariant* over `T` if `T` being a subtype of `U` implies `F` is a subtype of `F` (subtyping "passes through") * F is *contravariant* over `T` if `T` being a subtype of `U` implies - `F` is a subtype of `F` (subtyping is "inverted") + `F` is a subtype of `F` (subtyping is "inverted") * F is *invariant* over `T` otherwise (no subtyping relation can be derived) It should be noted that covariance is *far* more common and important than