Skip to content

Commit c369e4b

Browse files
authored
phantom-data: Add Send and Sync columns (#411)
1 parent 927dfbd commit c369e4b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/phantom-data.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ We do this using `PhantomData`, which is a special marker type. `PhantomData`
2424
consumes no space, but simulates a field of the given type for the purpose of
2525
static analysis. This was deemed to be less error-prone than explicitly telling
2626
the type-system the kind of variance that you want, while also providing other
27-
useful things such as the information needed by drop check.
27+
useful things such as auto traits and the information needed by drop check.
2828

2929
Iter logically contains a bunch of `&'a T`s, so this is exactly what we tell
3030
the `PhantomData` to simulate:
@@ -234,14 +234,14 @@ standard library made a utility for itself called `Unique<T>` which:
234234

235235
Here’s a table of all the wonderful ways `PhantomData` could be used:
236236

237-
| Phantom type | `'a` | `T` |
238-
|-----------------------------|-----------|---------------------------|
239-
| `PhantomData<T>` | - | covariant (with drop check) |
240-
| `PhantomData<&'a T>` | covariant | covariant |
241-
| `PhantomData<&'a mut T>` | covariant | invariant |
242-
| `PhantomData<*const T>` | - | covariant |
243-
| `PhantomData<*mut T>` | - | invariant |
244-
| `PhantomData<fn(T)>` | - | contravariant |
245-
| `PhantomData<fn() -> T>` | - | covariant |
246-
| `PhantomData<fn(T) -> T>` | - | invariant |
247-
| `PhantomData<Cell<&'a ()>>` | invariant | - |
237+
| Phantom type | `'a` | `T` | `Send` | `Sync` |
238+
|-----------------------------|-----------|-----------------------------|-----------|-----------|
239+
| `PhantomData<T>` | - | covariant (with drop check) | `T: Send` | `T: Sync` |
240+
| `PhantomData<&'a T>` | covariant | covariant | `T: Sync` | `T: Sync` |
241+
| `PhantomData<&'a mut T>` | covariant | invariant | `T: Send` | `T: Sync` |
242+
| `PhantomData<*const T>` | - | covariant | - | - |
243+
| `PhantomData<*mut T>` | - | invariant | - | - |
244+
| `PhantomData<fn(T)>` | - | contravariant | `Send` | `Sync` |
245+
| `PhantomData<fn() -> T>` | - | covariant | `Send` | `Sync` |
246+
| `PhantomData<fn(T) -> T>` | - | invariant | `Send` | `Sync` |
247+
| `PhantomData<Cell<&'a ()>>` | invariant | - | `Send` | - |

0 commit comments

Comments
 (0)