Closed
Description
From a discussion about different ways to write an Invariant type parameter marker; since we need to express it via PhantomData
.
candidates were basically (although this was only used for &'a ()
cases)
PhantomData<*mut T>
PhantomData<Cell<T>>
PhantomData<fn(T) -> T>
Which all have different drawbacks and incidental other implications.
The source of the confusion was (3) case not passing my simple test for invariance.
Because of the drawbacks, it seems it would be useful to have a real invariance marker in rust's libstd.
(1) and (2) make the type !Sync
. (2) has owns-T
implications (3) has bug #31200. All of (1), (2), (3) don't respond like Invarant<T>
should to custom new OIBITS.
cc @reem if you are interested.
Metadata
Metadata
Assignees
Labels
No labels