Description
Currently, you cannot even construct a Pin
unless the pointer it wraps implements Deref
. This means you cannot have a Pin<*const T>
, Pin<*mut T>
or Pin<NonNull<T>>
. We should consider extending the API of Pin to support these constructs.
Unfortunately, I don't know if there's much this actually helps, because we have no unsafe equivalent of Deref
as a trait abstraction. As a result, I think the only APIs that could apply to these pointers generically is:
unsafe fn new_unchecked(p: P) -> Pin<P>
unsafe fn into_inner(self: Pin<P>) -> P
This limits the utility of Pin
on these pointers, since it basically guarantees nothing with this API.
If we had an UnsafeAsRef
trait, we could support unsafe equivalents of as_ref
and as_mut
, allowing you to at least maintain the pinning invariant in your unsafe code. In other words, some sort of UnsafeAsRef
and UnsafeAsMut
traits would be necessary for this to actually be helpful. I'm not sure if those traits are worth adding.