Error code E0375
CoerceUnsized
or DispatchFromDyn
was implemented on a struct which contains
more than one field that is being unsized.
Erroneous code example:
ⓘ
CoerceUnsized
is used to coerce structs that have a field that can be unsized,
like a custom MyBox<T>
being unsized to MyBox<dyn Trait>
. DispatchFromDyn
is used to dispatch from MyBox<dyn Trait>
to MyBox<Self>
in a dyn-compatible
trait.
If the struct has multiple fields that must be unsized, then the compiler has no
way to generate a valid implementation of CoerceUnsized
or DispatchFromDyn
.
Note that CoerceUnsized
and DispatchFromDyn
is mainly used by smart pointers
like Box
, Rc
and Arc
to be able to mark that they can coerce unsized types
that they are pointing at.