Back to Developer Roadmap

Covariant and Contravariant Lifetimes

src/data/roadmaps/rust/content/[email protected]

4.0639 B
Original Source

Covariant and Contravariant Lifetimes

Variance describes how subtyping relationships change when types are nested. Covariant types preserve ordering (&'long T is subtype of &'short T), contravariant reverses it, invariant requires exact matches. Affects how lifetimes work with references, boxes, and function parameters.

Visit the following resources to learn more: