Error code E0374
CoerceUnsized
was implemented on a struct which does not contain a field with
an unsized type.
Example of erroneous code:
ⓘ
An unsized type is any type where the compiler does not know the length or alignment of at compile time. Any struct containing an unsized type is also unsized.
CoerceUnsized
is used to coerce one struct containing an unsized type
into another struct containing a different unsized type. If the struct
doesn't have any fields of unsized types then you don't need explicit
coercion to get the types you want. To fix this you can either
not try to implement CoerceUnsized
or you can add a field that is
unsized to the struct.
Example:
Note that CoerceUnsized
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.