Skip to content

Commit 0492daf

Browse files
conradludgateehuss
authored andcommitted
clarify some points
1 parent 9c17e30 commit 0492daf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/subtyping.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ However, a naive implementation of lifetimes would be either too restrictive,
55
or permit undefined behavior.
66

77
In order to allow flexible usage of lifetimes
8-
while also preventing mis-use, Rust uses a combination of **Subtyping** and **Variance**.
8+
while also preventing their misuse, Rust uses a combination of **Subtyping** and **Variance**.
99

1010
## Subtyping
1111

1212
Subtyping is the idea that one type can be a *subtype* of another.
13-
Let's define that `A: B` is equivalent to saying '`A` is a subtype of `B`'.
14-
What this is suggesting to us is that the set of *requirements* that `B` defines
15-
are completely satisfied by `A`. `A` may then have more requirements.
13+
14+
Let's define that `Sub` is a subtype of `Super` (we'll be using the notation `Sub: Super` throughout this chapter)
15+
16+
What this is suggesting to us is that the set of *requirements* that `Super` defines
17+
are completely satisfied by `Sub`. `Sub` may then have more requirements.
1618

1719
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)
1820

@@ -72,7 +74,7 @@ Now that we have a defined set of requirements for lifetimes, we can define how
7274
`'a` may define a region larger than `'b`, but that still fits our definition.
7375
Going back to our example above, we can say that `'static: 'b`.
7476

75-
For now, let's accept the idea that subtypes of lifetimes can be transitive (more on this in [Variance](#variance>)),
77+
For now, let's accept the idea that subtypes of lifetimes can be transitive (more on this in [Variance](#variance)),
7678
eg. `&'static str` is a subtype of `&'b str`, then we can let them coerce, and then the example above will compile
7779

7880
```rust

0 commit comments

Comments
 (0)