Skip to content

Commit fb0d2fd

Browse files
committed
remove dup material and make early/late intro short
1 parent c1750f8 commit fb0d2fd

File tree

1 file changed

+3
-36
lines changed

1 file changed

+3
-36
lines changed

src/early-late-bound.md

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,13 @@
11
# Early and Late Bound Variables
22

3-
A generic type may be [_universally_ or _existentially_ quantified][quant]. For
4-
example,
5-
6-
[quant]: ./appendix/background.md#quantified
7-
8-
```rust,ignore
9-
fn foo<T>()
10-
```
11-
This function claims that the function is well-typed for all types `T`. To use
12-
the chalk notation: `forall<T> foo<T>`.
13-
14-
Another example:
15-
16-
```rust,ignore
17-
fn foo<'a>(_: &'a usize)
18-
```
19-
This function claims that there is some lifetime `'a` (determined by the
20-
caller) such that it is well-typed.
21-
22-
One more example:
23-
24-
```rust,ignore
25-
fn foo<F>()
26-
where for<'a> F: Fn(&'a u8),
27-
```
28-
This function claims that for all lifetimes `'a` and types `F` satisfying the
29-
bound, it is well-typed:
30-
31-
```txt
32-
forall<'a, F> {
33-
if F: Fn(&'a u8) {
34-
foo<'a, f>
35-
}
36-
}
37-
```
38-
3+
In Rust, generic types are generally [_universally_ quantified][quant].
394
Notice, however, that in Rust, we don't have (at the language level)
405
universally quantified types; there is no `forall<F> foo<F>` in Rust. As a
416
result, we have a sort of weird split in how we represent some generic types:
427
_early-_ and _late-_ bound parameters.
438

9+
[quant]: ./appendix/background.md#quantified
10+
4411
Basically, if we cannot represent a type (e.g. a universally quantified type),
4512
we have to bind it _early_ so that the unrepresentable type is never around.
4613

0 commit comments

Comments
 (0)