An attempt to implement the Copy
trait for a struct failed because one of the fields does not implement Copy
. To fix this, you must implement Copy
for the mentioned field. Note that this may not be possible, as in the example of
struct Foo { foo : Vec<u32>, } impl Copy for Foo { }
This fails because Vec<T>
does not implement Copy
for any T
.
Here's another example that will fail:
#[derive(Copy)] struct Foo<'a> { ty: &'a mut bool, }
This fails because &mut T
is not Copy
, even when T
is Copy
(this differs from the behavior for &T
, which is always Copy
).