Trait that indicates that this is a pointer or a wrapper for one, where unsizing can be performed on the pointee.
For builtin pointer types, pointers to
T will coerce to pointers to
by converting from a thin pointer to a fat pointer.
For custom types, the coercion here works by coercing
provided an impl of
CoerceUnsized<Foo<U>> for Foo<T> exists.
Such an impl can only be written if
Foo<T> has only a single non-phantomdata
T. If the type of that field is
Bar<T>, an implementation
CoerceUnsized<Bar<U>> for Bar<T> must exist. The coercion will work by
Bar<T> field into
Bar<U> and filling in the rest of the fields
Foo<T> to create a
Foo<U>. This will effectively drill down to a pointer
field and coerce that.
Generally, for smart pointers you will implement
CoerceUnsized<Ptr<U>> for Ptr<T> where T: Unsize<U>, U: ?Sized, with an
?Sized bound on
T itself. For wrapper types that directly embed
can directly implement
CoerceUnsized<Wrap<U>> for Wrap<T> where T: CoerceUnsized<U>.
This will let coercions of types like
Unsize is used to mark types which can be coerced to DSTs if behind
pointers. It is implemented automatically by the compiler.
impl<P, U> CoerceUnsized<Pin<U>> for Pin<P> where[src]