|
|
@ -27,7 +27,7 @@ useful such as the information needed by drop check.
|
|
|
|
Iter logically contains a bunch of `&'a T`s, so this is exactly what we tell
|
|
|
|
Iter logically contains a bunch of `&'a T`s, so this is exactly what we tell
|
|
|
|
the PhantomData to simulate:
|
|
|
|
the PhantomData to simulate:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```rust
|
|
|
|
use std::marker;
|
|
|
|
use std::marker;
|
|
|
|
|
|
|
|
|
|
|
|
struct Iter<'a, T: 'a> {
|
|
|
|
struct Iter<'a, T: 'a> {
|
|
|
@ -42,7 +42,7 @@ over `'a` and `T`. Everything Just Works.
|
|
|
|
|
|
|
|
|
|
|
|
Another important example is Vec, which is (approximately) defined as follows:
|
|
|
|
Another important example is Vec, which is (approximately) defined as follows:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```rust
|
|
|
|
struct Vec<T> {
|
|
|
|
struct Vec<T> {
|
|
|
|
data: *const T, // *const for variance!
|
|
|
|
data: *const T, // *const for variance!
|
|
|
|
len: usize,
|
|
|
|
len: usize,
|
|
|
@ -66,7 +66,7 @@ In order to tell dropck that we *do* own values of type T, and therefore may
|
|
|
|
drop some T's when *we* drop, we must add an extra PhantomData saying exactly
|
|
|
|
drop some T's when *we* drop, we must add an extra PhantomData saying exactly
|
|
|
|
that:
|
|
|
|
that:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```rust
|
|
|
|
use std::marker;
|
|
|
|
use std::marker;
|
|
|
|
|
|
|
|
|
|
|
|
struct Vec<T> {
|
|
|
|
struct Vec<T> {
|
|
|
|