@@ -13,10 +13,12 @@ struct Iter<'a, T: 'a> {
13
13
```
14
14
15
15
However because ` 'a ` is unused within the struct's body, it's * unbounded* .
16
- Because of the troubles this has historically caused, unbounded lifetimes and
17
- types are * forbidden* in struct definitions. Therefore we must somehow refer
18
- to these types in the body. Correctly doing this is necessary to have
19
- correct variance and drop checking.
16
+ [ Because of the troubles this has historically caused] [ unused-param ] ,
17
+ unbounded lifetimes and types are * forbidden* in struct definitions.
18
+ Therefore we must somehow refer to these types in the body.
19
+ Correctly doing this is necessary to have correct variance and drop checking.
20
+
21
+ [ unused-param ] : https://rust-lang.github.io/rfcs/0738-variance.html#the-corner-case-unused-parameters-and-parameters-that-are-only-used-unsafely
20
22
21
23
We do this using ` PhantomData ` , which is a special marker type. ` PhantomData `
22
24
consumes no space, but simulates a field of the given type for the purpose of
@@ -25,7 +27,7 @@ the type-system the kind of variance that you want, while also providing other
25
27
useful things such as the information needed by drop check.
26
28
27
29
Iter logically contains a bunch of ` &'a T ` s, so this is exactly what we tell
28
- the PhantomData to simulate:
30
+ the ` PhantomData ` to simulate:
29
31
30
32
``` rust
31
33
use std :: marker;
@@ -63,7 +65,7 @@ soundness. This will in turn allow people to create unsoundness using
63
65
Vec's destructor.
64
66
65
67
In order to tell dropck that we * do* own values of type T, and therefore may
66
- drop some T's when * we* drop, we must add an extra PhantomData saying exactly
68
+ drop some T's when * we* drop, we must add an extra ` PhantomData ` saying exactly
67
69
that:
68
70
69
71
``` rust
0 commit comments