while also preventing their misuse, Rust uses a combination of **Subtyping** and **Variance**.
while also preventing their misuse, Rust uses a combination of **Subtyping** and **Variance**.
## Subtyping
Let's start with a example.
Subtyping is the idea that one type can be used in place of another.
Let's define that `Sub` is a subtype of `Super` (we'll be using the notation `Sub: Super` throughout this chapter)
What this is suggesting to us is that the set of *requirements* that `Super` defines
are completely satisfied by `Sub`. `Sub` may then have more requirements.
An example of simple subtyping that exists in the language are [supertraits](https://doc.rust-lang.org/stable/book/ch19-03-advanced-traits.html?highlight=supertraits#using-supertraits-to-require-one-traits-functionality-within-another-trait)
Here, we have that `Error: fmt::Display` (`Error` is a *subtype* of `Display`),
because it has all the requirements of `fmt::Display`, plus the `source`/`description`/`cause` functions.
However, subtyping in traits is not that interesting in the case of Rust.
Here in the nomicon, we're going to focus more with how subtyping interacts with **lifetimes**
Take this example
```rust
```rust
fn debug<T:std::fmt::Debug>(a: T, b: T) {
fn debug<T:std::fmt::Debug>(a: T, b: T) {
@ -68,16 +41,53 @@ This would be rather unfortunate. In this case,
what we want is to accept any type that lives *at least as long* as `'b`.
what we want is to accept any type that lives *at least as long* as `'b`.
Let's try using subtyping with our lifetimes.
Let's try using subtyping with our lifetimes.
Let's define a lifetime to have the a simple set of requirements:
## Subtyping
Subtyping is the idea that one type can be used in place of another.
Let's define that `Sub` is a subtype of `Super` (we'll be using the notation `Sub: Super` throughout this chapter)
What this is suggesting to us is that the set of *requirements* that `Super` defines
are completely satisfied by `Sub`. `Sub` may then have more requirements.
An example of simple subtyping that exists in the language are [supertraits](https://doc.rust-lang.org/stable/book/ch19-03-advanced-traits.html?highlight=supertraits#using-supertraits-to-require-one-traits-functionality-within-another-trait)