This code (also on play)
use std::sync::Arc;
struct Foo {
x: isize, // Something complex in actual code, implements Drop
}
#[derive(Clone)]
struct Good {
a: Option<Arc<Foo>>,
b: Option<Arc<Foo>>,
c: Option<Arc<Foo>>,
}
#[derive(Clone)]
struct Bad {
x: [Option<Arc<Foo>>; 3],
}
fn main() {
println!("See?");
}
fails for Bad
with
<anon>:16:5: 16:29 error: the trait `core::marker::Copy` is not implemented for the type `alloc::arc::Arc<Foo>` [E0277]
<anon>:16 x: [Option<Arc<Foo>>; 3],
^~~~~~~~~~~~~~~~~~~~~~~~
<anon>:14:10: 14:15 note: in expansion of #[derive_Clone]
but it has no problem with Good
.
- Why is this and,
- is there any workaround? I am not exactly keen on handling 12 independent fields.